diff --git a/AllBase/AllBase.csproj b/AllBase/AllBase.csproj index 66ec721..0836d1b 100644 --- a/AllBase/AllBase.csproj +++ b/AllBase/AllBase.csproj @@ -56,6 +56,8 @@ false false false + + true diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index 3dff292..b780d32 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -27,7 +27,7 @@ namespace AllBase /// /// 版本ID /// - public static int VersionCount = 358; + public static int VersionCount = 359; /// /// 版本号 diff --git a/TEMUKJD/KJD.csproj b/TEMUKJD/KJD.csproj index 849bd4d..672775f 100644 --- a/TEMUKJD/KJD.csproj +++ b/TEMUKJD/KJD.csproj @@ -18,6 +18,21 @@ true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -42,7 +57,7 @@ true - qk.ico + icon.ico true @@ -69,7 +84,7 @@ ..\bin\ DEBUG;TRACE full - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true @@ -77,10 +92,10 @@ ..\bin\ - TRACE + DEBUG;TRACE true pdbonly - x86 + AnyCPU prompt MinimumRecommendedRules.ruleset true @@ -1228,7 +1243,13 @@ - + + + False + .NET Framework 3.5 SP1 + false + + diff --git a/TEMUKJD/KJD.csproj.user b/TEMUKJD/KJD.csproj.user index 9b86104..7a74901 100644 --- a/TEMUKJD/KJD.csproj.user +++ b/TEMUKJD/KJD.csproj.user @@ -2,5 +2,13 @@ ShowAllFiles + publish\ + + + + + + zh-CN + false \ No newline at end of file diff --git a/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.Designer.cs b/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.Designer.cs index 0371668..4f6930b 100644 --- a/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.Designer.cs +++ b/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.Designer.cs @@ -30,17 +30,19 @@ namespace TemuKJD.KJDForms.ProductForms private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.ucGroupBoxEx4 = new TemuKJD.UserComponent.UcGroupBoxEx(this.components); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.lblMinBound = new System.Windows.Forms.Label(); this.txtMinBound = new System.Windows.Forms.TextBox(); this.label15 = new System.Windows.Forms.Label(); - this.lblMinBound = new System.Windows.Forms.Label(); + this.chkIfLessMakeZero = new System.Windows.Forms.CheckBox(); this.txtScale2 = new System.Windows.Forms.TextBox(); this.label14 = new System.Windows.Forms.Label(); this.txtScale1 = new System.Windows.Forms.TextBox(); @@ -137,12 +139,13 @@ namespace TemuKJD.KJDForms.ProductForms this.statusBar = new TemuKJD.UserControls.StatusBarUserControl(); this.panelEx1 = new DevComponents.DotNetBar.PanelEx(); this.btnClear = new DevComponents.DotNetBar.PanelEx(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.label18 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.ucGroupBoxEx4.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); this.ucGroupBoxEx3.SuspendLayout(); this.ucGroupBoxEx2.SuspendLayout(); this.ucGroupBoxEx1.SuspendLayout(); @@ -167,7 +170,6 @@ namespace TemuKJD.KJDForms.ProductForms this.splitContainer4.Panel1.SuspendLayout(); this.splitContainer4.Panel2.SuspendLayout(); this.splitContainer4.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -209,6 +211,7 @@ namespace TemuKJD.KJDForms.ProductForms this.ucGroupBoxEx4.Controls.Add(this.label10); this.ucGroupBoxEx4.Controls.Add(this.label16); this.ucGroupBoxEx4.Controls.Add(this.label17); + this.ucGroupBoxEx4.Controls.Add(this.label18); this.ucGroupBoxEx4.Location = new System.Drawing.Point(397, 2); this.ucGroupBoxEx4.Name = "ucGroupBoxEx4"; this.ucGroupBoxEx4.Size = new System.Drawing.Size(749, 120); @@ -216,10 +219,31 @@ namespace TemuKJD.KJDForms.ProductForms this.ucGroupBoxEx4.TabStop = false; this.ucGroupBoxEx4.Text = "创建备货单"; // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.lblMinBound); + this.flowLayoutPanel1.Controls.Add(this.txtMinBound); + this.flowLayoutPanel1.Controls.Add(this.label15); + this.flowLayoutPanel1.Controls.Add(this.chkIfLessMakeZero); + this.flowLayoutPanel1.Location = new System.Drawing.Point(240, 83); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(433, 31); + this.flowLayoutPanel1.TabIndex = 702; + // + // lblMinBound + // + this.lblMinBound.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblMinBound.AutoSize = true; + this.lblMinBound.Location = new System.Drawing.Point(3, 5); + this.lblMinBound.Name = "lblMinBound"; + this.lblMinBound.Size = new System.Drawing.Size(87, 17); + this.lblMinBound.TabIndex = 691; + this.lblMinBound.Text = "备货量小于3按"; + // // txtMinBound // this.txtMinBound.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.txtMinBound.Location = new System.Drawing.Point(105, 0); + this.txtMinBound.Location = new System.Drawing.Point(93, 2); this.txtMinBound.Margin = new System.Windows.Forms.Padding(0); this.txtMinBound.Name = "txtMinBound"; this.txtMinBound.Size = new System.Drawing.Size(39, 23); @@ -232,21 +256,25 @@ namespace TemuKJD.KJDForms.ProductForms // this.label15.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(147, 3); + this.label15.Location = new System.Drawing.Point(135, 5); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(32, 17); this.label15.TabIndex = 692; this.label15.Text = "备货"; // - // lblMinBound + // chkIfLessMakeZero // - this.lblMinBound.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.lblMinBound.AutoSize = true; - this.lblMinBound.Location = new System.Drawing.Point(3, 3); - this.lblMinBound.Name = "lblMinBound"; - this.lblMinBound.Size = new System.Drawing.Size(99, 17); - this.lblMinBound.TabIndex = 691; - this.lblMinBound.Text = "备货数量小于3按"; + this.chkIfLessMakeZero.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.chkIfLessMakeZero.AutoSize = true; + this.chkIfLessMakeZero.Checked = true; + this.chkIfLessMakeZero.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkIfLessMakeZero.Location = new System.Drawing.Point(183, 3); + this.chkIfLessMakeZero.Margin = new System.Windows.Forms.Padding(13, 3, 3, 3); + this.chkIfLessMakeZero.Name = "chkIfLessMakeZero"; + this.chkIfLessMakeZero.Size = new System.Drawing.Size(207, 21); + this.chkIfLessMakeZero.TabIndex = 693; + this.chkIfLessMakeZero.Text = "平台允许量小于最小备货量不备货"; + this.chkIfLessMakeZero.UseVisualStyleBackColor = true; // // txtScale2 // @@ -661,18 +689,18 @@ namespace TemuKJD.KJDForms.ProductForms // this.dgvShop.AllowUserToAddRows = false; this.dgvShop.AllowUserToDeleteRows = false; - dataGridViewCellStyle7.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvShop.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dgvShop.BackgroundColor = System.Drawing.Color.White; this.dgvShop.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvShop.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.dgvShop.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvShop.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colSelect, @@ -687,8 +715,8 @@ namespace TemuKJD.KJDForms.ProductForms this.dgvShop.Name = "dgvShop"; this.dgvShop.ReadOnly = true; this.dgvShop.RowHeadersWidth = 30; - dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.dgvShop.RowsDefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dgvShop.RowsDefaultCellStyle = dataGridViewCellStyle3; this.dgvShop.RowTemplate.Height = 23; this.dgvShop.Size = new System.Drawing.Size(266, 435); this.dgvShop.TabIndex = 6; @@ -1250,18 +1278,18 @@ namespace TemuKJD.KJDForms.ProductForms // this.dgvStock.AllowUserToAddRows = false; this.dgvStock.AllowUserToDeleteRows = false; - dataGridViewCellStyle10.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvStock.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvStock.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; this.dgvStock.BackgroundColor = System.Drawing.Color.White; this.dgvStock.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvStock.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvStock.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; this.dgvStock.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvStock.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colUpId, @@ -1287,8 +1315,8 @@ namespace TemuKJD.KJDForms.ProductForms this.dgvStock.Location = new System.Drawing.Point(0, 0); this.dgvStock.Name = "dgvStock"; this.dgvStock.ReadOnly = true; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.dgvStock.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dgvStock.RowsDefaultCellStyle = dataGridViewCellStyle6; this.dgvStock.RowTemplate.Height = 23; this.dgvStock.Size = new System.Drawing.Size(870, 435); this.dgvStock.TabIndex = 187; @@ -1527,15 +1555,15 @@ namespace TemuKJD.KJDForms.ProductForms this.btnClear.Text = "清空结果"; this.btnClear.Visible = false; // - // flowLayoutPanel1 + // label18 // - this.flowLayoutPanel1.Controls.Add(this.lblMinBound); - this.flowLayoutPanel1.Controls.Add(this.txtMinBound); - this.flowLayoutPanel1.Controls.Add(this.label15); - this.flowLayoutPanel1.Location = new System.Drawing.Point(180, 83); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(284, 31); - this.flowLayoutPanel1.TabIndex = 702; + this.label18.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label18.AutoSize = true; + this.label18.Location = new System.Drawing.Point(170, 88); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(80, 17); + this.label18.TabIndex = 712; + this.label18.Text = "最小备货量:"; // // SaleStockUpForm // @@ -1554,6 +1582,8 @@ namespace TemuKJD.KJDForms.ProductForms this.splitContainer1.ResumeLayout(false); this.ucGroupBoxEx4.ResumeLayout(false); this.ucGroupBoxEx4.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); this.ucGroupBoxEx3.ResumeLayout(false); this.ucGroupBoxEx2.ResumeLayout(false); this.ucGroupBoxEx2.PerformLayout(); @@ -1586,8 +1616,6 @@ namespace TemuKJD.KJDForms.ProductForms this.splitContainer4.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer4)).EndInit(); this.splitContainer4.ResumeLayout(false); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -1696,5 +1724,7 @@ namespace TemuKJD.KJDForms.ProductForms private System.Windows.Forms.Label label16; private System.Windows.Forms.Label label17; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.CheckBox chkIfLessMakeZero; + private System.Windows.Forms.Label label18; } } \ No newline at end of file diff --git a/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.cs b/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.cs index 8883aa9..8db32e9 100644 --- a/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.cs +++ b/TEMUKJD/KJDForms/ProductForms/SaleStockUpForm.cs @@ -767,8 +767,11 @@ namespace TemuKJD.KJDForms.ProductForms sku.wantStockUpBound = sku.todaySaleVolume.ParseToInt() * scale - sku.inventoryNumInfo.warehouseInventoryNum.ParseToInt() - sku.inventoryNumInfo.waitReceiveNum.ParseToInt(); - if (sku.wantStockUpBound > 0 && sku.wantStockUpBound < this.txtMinBound.Text.ParseToInt()) - sku.wantStockUpBound = this.txtMinBound.Text.ParseToInt(); + Invoke(new Action(() => + { + if (sku.wantStockUpBound > 0 && sku.wantStockUpBound < this.txtMinBound.Text.ParseToInt()) + sku.wantStockUpBound = this.txtMinBound.Text.ParseToInt(); + })); sku.wantStockUpBound = Math.Max(sku.wantStockUpBound, 0); } if (sInfo.skuQuantityDetailList.Any(s => s.wantStockUpBound > 0)) @@ -964,6 +967,12 @@ namespace TemuKJD.KJDForms.ProductForms if (sku.wantStockUpBound > sBaseSku.applyUpperBound.ParseToInt()) { sku.wantStockUpBound = sBaseSku.applyUpperBound.ParseToInt(); + //如果强制要求最小数量,且平台可备数量小于最小数量,直接不允许备货 + Invoke(new Action(() => + { + if (sku.wantStockUpBound < this.txtMinBound.Text.ParseToInt() && this.chkIfLessMakeZero.Checked) + sku.wantStockUpBound = -1; + })); } } @@ -1034,7 +1043,8 @@ namespace TemuKJD.KJDForms.ProductForms private void txtMinBound_TextChanged(object sender, EventArgs e) { - this.lblMinBound.Text = "备货数量小于" + txtMinBound.Text.ParseToInt() + "按"; + this.lblMinBound.Text = "备货量小于" + txtMinBound.Text.ParseToInt() + "按"; + //this.chkIfLessMakeZero.Text = "平台允许备货数量小于" + txtMinBound.Text.ParseToInt() + "不备货"; } } } diff --git a/TEMUKJD/UserForm/LoginForm.cs b/TEMUKJD/UserForm/LoginForm.cs index a8109aa..478352d 100644 --- a/TEMUKJD/UserForm/LoginForm.cs +++ b/TEMUKJD/UserForm/LoginForm.cs @@ -435,12 +435,16 @@ namespace TemuKJD.UserForm public static void GetUserList() { - if (File.Exists("config\\user_login_config")) + //if (File.Exists("config\\user_login_config")) { try { - var txt = FileBase.ReadAllText("config\\user_login_config", System.Text.Encoding.UTF8); - UserParamList = JsonHelper.DeserializeJsonToList(txt); + //var txt = FileBase.ReadAllText("config\\user_login_config", System.Text.Encoding.UTF8); + //UserParamList = JsonHelper.DeserializeJsonToList(txt); + + UserParamList = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("user_login_config"); + if (UserParamList == null) + UserParamList = new List(); } catch { @@ -451,18 +455,20 @@ namespace TemuKJD.UserForm public static void SaveUserList() { - if (!Directory.Exists("config")) - { - Directory.CreateDirectory("config"); - } - try - { - var txt = JsonHelper.SerializeObject(UserParamList); - FileBase.WriteAllText("config\\user_login_config", txt, System.Text.Encoding.UTF8); - } - catch - { - } + //if (!Directory.Exists("config")) + //{ + // Directory.CreateDirectory("config"); + //} + //try + //{ + // var txt = JsonHelper.SerializeObject(UserParamList); + // FileBase.WriteAllText("config\\user_login_config", txt, System.Text.Encoding.UTF8); + //} + //catch + //{ + //} + + NaiBa.Util.Helper.ConfigHelper.SaveConfig("user_login_config", UserParamList); } private void lblBuy_Click(object sender, EventArgs e) diff --git a/Update/Update/MainForm.cs b/Update/Update/MainForm.cs index a6b74d8..cafa314 100644 --- a/Update/Update/MainForm.cs +++ b/Update/Update/MainForm.cs @@ -31,13 +31,14 @@ namespace Update SetFormRoundRectRgn(this, 7); SetFormRoundRectRgn(panel2, 7); SetFormRoundRectRgn(this.btnOk, 7); + SetFormRoundRectRgn(this.btnCancel, 7); } private void btnOk_Click(object sender, EventArgs e) { if (lblMessage.Text == "升级完成,点击确定重启程序") { - string extPath = System.Environment.CurrentDirectory + "\\" + Program.softName; + string extPath = System.Environment.CurrentDirectory + "\\" + Program.softName.Replace(".exe", "") + ".exe"; System.Diagnostics.Process.Start(extPath); Application.Exit(); return; @@ -73,6 +74,16 @@ namespace Update string tempFile = upTempPath + "\\" + Program.updateUrl.Substring(Program.updateUrl.LastIndexOf("/") + 1); bool result = Program.DownloadFile(Program.updateUrl, tempFile); + while (true) + { + Invoke(new Action(() => + { + progressBar1.Value = Program.progress; + })); + if (Program.progress == 100) + break; + } + if (result) { ZipFile.ExtractToDirectory(tempFile, upTempPath); @@ -110,6 +121,7 @@ namespace Update Thread.Sleep(50); Invoke(new Action(() => { + progressBar1.Value = 100; lblMessage.Text = "升级完成,点击确定重启程序"; btnOk.Enabled = true; })); @@ -118,6 +130,7 @@ namespace Update { Invoke(new Action(() => { + progressBar1.Value = 100; this.lblMessage.Text = "升级失败,未获取到升级文件"; btnOk.Enabled = true; })); @@ -204,10 +217,18 @@ namespace Update private void CloseMainProgram() { string in_sAppName = Program.softName; //(一个word文档程序) + in_sAppName = in_sAppName.Replace(".exe", ""); try { System.Diagnostics.Process[] psiNewcas = System.Diagnostics.Process.GetProcessesByName(in_sAppName); + //System.Diagnostics.Process.GetProcessesByName(""); + + //var pro = System.Diagnostics.Process.GetProcesses(); + //foreach(var p in pro) + //{ + // Console.WriteLine(p.ProcessName); + //} foreach (System.Diagnostics.Process p in psiNewcas) { diff --git a/Update/Update/MainForm.designer.cs b/Update/Update/MainForm.designer.cs index cde1a00..895b062 100644 --- a/Update/Update/MainForm.designer.cs +++ b/Update/Update/MainForm.designer.cs @@ -81,6 +81,7 @@ namespace Update this.btnCancel.TabStop = false; this.btnCancel.Text = "取 消"; this.btnCancel.UseVisualStyleBackColor = false; + this.btnCancel.Visible = false; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // panel1 @@ -103,7 +104,7 @@ namespace Update this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnClose.Font = new System.Drawing.Font("微软雅黑", 11F); this.btnClose.ForeColor = System.Drawing.Color.White; - this.btnClose.Location = new System.Drawing.Point(240, -8); + this.btnClose.Location = new System.Drawing.Point(238, -5); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(17, 28); this.btnClose.TabIndex = 11; diff --git a/Update/Update/Program.cs b/Update/Update/Program.cs index 912cd36..1c99536 100644 --- a/Update/Update/Program.cs +++ b/Update/Update/Program.cs @@ -17,6 +17,7 @@ namespace Update public static int newVersion = 0; public static string updateUrl = ""; public static List updateFileUrls = new List(); + public static int progress = 0; /// /// 应用程序的主入口点。 @@ -29,7 +30,7 @@ namespace Update try { var text = File.ReadAllText("UpdateConfig.ini"); - //File.Delete("UpdateConfig.ini"); + File.Delete("UpdateConfig.ini"); var arr = text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length > 3) @@ -56,76 +57,76 @@ namespace Update } } - public static string HttpRequestPost(string url, string postData, string cookies = "", string codeType = "utf-8", string accept = "", string contentType = "") - { - HttpWebResponse response = null; - string result; - try - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - request.Method = "POST"; - request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; - if (!string.IsNullOrEmpty(accept)) - request.Accept = accept; - request.ContentType = "application/x-www-form-urlencoded; charset=" + codeType; - if (!string.IsNullOrEmpty(contentType)) - request.ContentType = contentType; + //public static string HttpRequestPost(string url, string postData, string cookies = "", string codeType = "utf-8", string accept = "", string contentType = "") + //{ + // HttpWebResponse response = null; + // string result; + // try + // { + // HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + // request.Method = "POST"; + // request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; + // if (!string.IsNullOrEmpty(accept)) + // request.Accept = accept; + // request.ContentType = "application/x-www-form-urlencoded; charset=" + codeType; + // if (!string.IsNullOrEmpty(contentType)) + // request.ContentType = contentType; - request.Referer = url; - request.AllowAutoRedirect = false; - if (!string.IsNullOrEmpty(cookies)) - request.Headers.Set(HttpRequestHeader.Cookie, cookies); + // request.Referer = url; + // request.AllowAutoRedirect = false; + // if (!string.IsNullOrEmpty(cookies)) + // request.Headers.Set(HttpRequestHeader.Cookie, cookies); - byte[] byteData = Encoding.GetEncoding(codeType).GetBytes(postData); - request.ContentLength = byteData.Length; - using (Stream requestStream = request.GetRequestStream()) - { - requestStream.Write(byteData, 0, byteData.Length); - } + // byte[] byteData = Encoding.GetEncoding(codeType).GetBytes(postData); + // request.ContentLength = byteData.Length; + // using (Stream requestStream = request.GetRequestStream()) + // { + // requestStream.Write(byteData, 0, byteData.Length); + // } - response = (HttpWebResponse)request.GetResponse(); - } - catch (WebException ex) - { - if (ex.Status == WebExceptionStatus.ProtocolError) - { - response = (HttpWebResponse)ex.Response; - result = ReadResponse(response); - if (response != null) response.Close(); - return result; - } - else return ex.Message; - } - catch (Exception e) - { - if (response != null) response.Close(); - return e.Message; - } - result = ReadResponse(response); - if (response != null) response.Close(); - return result; - } + // response = (HttpWebResponse)request.GetResponse(); + // } + // catch (WebException ex) + // { + // if (ex.Status == WebExceptionStatus.ProtocolError) + // { + // response = (HttpWebResponse)ex.Response; + // result = ReadResponse(response); + // if (response != null) response.Close(); + // return result; + // } + // else return ex.Message; + // } + // catch (Exception e) + // { + // if (response != null) response.Close(); + // return e.Message; + // } + // result = ReadResponse(response); + // if (response != null) response.Close(); + // return result; + //} - public static string ReadResponse(HttpWebResponse response) - { - using (Stream responseStream = response.GetResponseStream()) - { - Stream streamToRead = responseStream; - if (response.ContentEncoding.ToLower().Contains("gzip")) - { - streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress); - } - else if (response.ContentEncoding.ToLower().Contains("deflate")) - { - streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress); - } + //public static string ReadResponse(HttpWebResponse response) + //{ + // using (Stream responseStream = response.GetResponseStream()) + // { + // Stream streamToRead = responseStream; + // if (response.ContentEncoding.ToLower().Contains("gzip")) + // { + // streamToRead = new GZipStream(streamToRead, CompressionMode.Decompress); + // } + // else if (response.ContentEncoding.ToLower().Contains("deflate")) + // { + // streamToRead = new DeflateStream(streamToRead, CompressionMode.Decompress); + // } - using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8)) - { - return streamReader.ReadToEnd(); - } - } - } + // using (StreamReader streamReader = new StreamReader(streamToRead, Encoding.UTF8)) + // { + // return streamReader.ReadToEnd(); + // } + // } + //} /// /// 获取json中的int值 @@ -133,16 +134,16 @@ namespace Update /// /// /// - public static int GetIntJson(ref string html, string reg) - { - string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]"); - if (string.IsNullOrEmpty(temp)) - temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d-]+)"); - int i; - if (int.TryParse(temp, out i)) - return i; - return 0; - } + //public static int GetIntJson(ref string html, string reg) + //{ + // string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]"); + // if (string.IsNullOrEmpty(temp)) + // temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d-]+)"); + // int i; + // if (int.TryParse(temp, out i)) + // return i; + // return 0; + //} /// /// 获取字符串 @@ -150,17 +151,17 @@ namespace Update /// /// /// - public static string GetStringJson(ref string html, string reg) - { - string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]"); - if (string.IsNullOrEmpty(temp)) - temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d]+)"); - if (!string.IsNullOrEmpty(temp) && temp.Contains("\"")) - temp = temp.Substring(0, temp.IndexOf("\"")); - if (!string.IsNullOrEmpty(temp) && temp.Contains("'")) - temp = temp.Substring(0, temp.IndexOf("'")); - return temp; - } + //public static string GetStringJson(ref string html, string reg) + //{ + // string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]"); + // if (string.IsNullOrEmpty(temp)) + // temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d]+)"); + // if (!string.IsNullOrEmpty(temp) && temp.Contains("\"")) + // temp = temp.Substring(0, temp.IndexOf("\"")); + // if (!string.IsNullOrEmpty(temp) && temp.Contains("'")) + // temp = temp.Substring(0, temp.IndexOf("'")); + // return temp; + //} /// /// 返回单个正则匹配项 @@ -168,18 +169,18 @@ namespace Update /// /// /// - public static string GetMatchRegexString(string sourceString, string RegexString) - { - if (!string.IsNullOrEmpty(sourceString)) - { - MatchCollection mc = Regex.Matches(sourceString, RegexString, RegexOptions.IgnoreCase); - if (mc.Count > 0) - { - return mc[0].Groups[1].Value.ToString(); - } - } - return null; - } + //public static string GetMatchRegexString(string sourceString, string RegexString) + //{ + // if (!string.IsNullOrEmpty(sourceString)) + // { + // MatchCollection mc = Regex.Matches(sourceString, RegexString, RegexOptions.IgnoreCase); + // if (mc.Count > 0) + // { + // return mc[0].Groups[1].Value.ToString(); + // } + // } + // return null; + //} /// /// 下载文件 @@ -192,10 +193,12 @@ namespace Update try { WebClientUtils webClient = new WebClientUtils(); - webClient.Timeout = 300; + webClient.Timeout = 600; if (File.Exists(FilePath)) File.Delete(FilePath); - webClient.DownloadFile(Urlstring, FilePath); + webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged; + var uri = new Uri(Urlstring); + webClient.DownloadFileAsync(uri, FilePath); return true; } catch (Exception ex) @@ -203,5 +206,10 @@ namespace Update return false; } } + + private static void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) + { + progress = e.ProgressPercentage; + } } } diff --git a/Update/Update/Update.csproj b/Update/Update/Update.csproj index 70e0543..dba7ba8 100644 --- a/Update/Update/Update.csproj +++ b/Update/Update/Update.csproj @@ -29,7 +29,7 @@ AnyCPU pdbonly true - bin\Release\ + ..\..\bin\ TRACE prompt 4 diff --git a/Work/Initialization.cs b/Work/Initialization.cs index b187e07..c752b71 100644 --- a/Work/Initialization.cs +++ b/Work/Initialization.cs @@ -341,7 +341,7 @@ offCountPara,false;offProductPara,100;IrregularitiesPara,true;noNeerPara,true;no if (File.Exists(updatefilepath)) { File.WriteAllText(System.Environment.CurrentDirectory + "\\UpdateConfig.ini", - "TemuKJD.exe\r\n" + + "TemuKJD\r\n" + BaseClass.VersionCount + "\r\n" + newVersion + "\r\n" + updateFileAddress); diff --git a/Work/Work.csproj b/Work/Work.csproj index 9d88b1a..e260e75 100644 --- a/Work/Work.csproj +++ b/Work/Work.csproj @@ -34,6 +34,7 @@ prompt 4 false + x86 true