⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frminitial.cs

📁 汽车销售管理系统,进销存系统典范,值得初学者多多学习
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiAdd", System.Data.SqlDbType.VarChar, 100, "osiAdd"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiTel", System.Data.SqlDbType.VarChar, 100, "osiTel"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiWeb", System.Data.SqlDbType.VarChar, 100, "osiWeb"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiInDepotCode", System.Data.SqlDbType.VarChar, 10, "osiInDepotCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiMoveCode", System.Data.SqlDbType.VarChar, 10, "osiMoveCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiSellCode", System.Data.SqlDbType.VarChar, 10, "osiSellCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiGatheringCode", System.Data.SqlDbType.VarChar, 10, "osiGatheringCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiCommissionCode", System.Data.SqlDbType.VarChar, 10, "osiCommissionCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiPayCode", System.Data.SqlDbType.VarChar, 10, "osiPayCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiPreCode", System.Data.SqlDbType.VarChar, 10, "osiPreCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@osiStoCode", System.Data.SqlDbType.VarChar, 10, "osiStoCode"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiAdd", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiAdd", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiCommissionCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiCommissionCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiGatheringCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiGatheringCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiInDepotCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiInDepotCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiMoveCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiMoveCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiName", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiName", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiPayCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiPayCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiPreCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiPreCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiSellCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiSellCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiStoCode", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiStoCode", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiTel", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiTel", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_osiWeb", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "osiWeb", System.Data.DataRowVersion.Original, null));
			// 
			// _sqlCom
			// 
			this._sqlCom.CommandText = "SELECT uJob FROM tblUser WHERE (uCode = @userID)";
			this._sqlCom.Connection = this._sqlCon;
			this._sqlCom.Parameters.Add(new System.Data.SqlClient.SqlParameter("@userID", System.Data.SqlDbType.VarChar, 10, "uCode"));
			// 
			// frmInitial
			// 
			this.AcceptButton = this.btnConfirm;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.WhiteSmoke;
			this.ClientSize = new System.Drawing.Size(520, 341);
			this.Controls.Add(this.btnConfirm);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnCancel);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.KeyPreview = true;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmInitial";
			this.Text = "设定系统初始参数";
			this.Load += new System.EventHandler(this.frmInitial_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this._dsOsINI1)).EndInit();
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnConfirm_Click(object sender, System.EventArgs e)
		{
			try
			{
				if(!CheckTextBox())
					return;
				foreach(DataRow row in this._dsOsINI1.tblOsInit.Rows)
				{
					row.EndEdit();
				}
				this._sqlCon.Open();
				this._sqlAdap.Update(this._dsOsINI1);
				this.Close();
			}
			catch(SqlException ex)
			{
				MessageBox.Show("数据库操作错误!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			catch(Exception et)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。","系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
			finally
			{
				this._sqlCon.Close();
			}
		}
		private bool CheckTextBox()
		{
			if(this.txtCName.Text=="")
			{
				MessageBox.Show("公司名称不得为空!");
				this.txtCName.Focus();
				return false;
			}
			if(this.txtCAdd.Text=="")
			{
				MessageBox.Show("公司地址不得为空!");
				this.txtCAdd.Focus();
				return false;
			}
			if(this.txtCPhone.Text=="")
			{
				MessageBox.Show("公司电话不得为空!");
				this.txtCPhone.Focus();
				return false;
			}
			if(this.txtCWeb.Text=="")
			{
				MessageBox.Show("公司网址不得为空!");
				this.txtCWeb.Focus();
				return false;
			}
			if(this.txtCommit.Text=="")
			{
				MessageBox.Show("代办单号不得为空!");
				this.txtCommit.Focus();
				return false;
			}
			if(this.txtGet.Text=="")
			{
				MessageBox.Show("受款单号不得为空!");
				this.txtGet.Focus();
				return false;
			}
			if(this.txtInDepot.Text=="")
			{
				MessageBox.Show("入库单号不得为空!");
				this.txtInDepot.Focus();
				return false;
			}
			if(this.txtMove.Text=="")
			{
				MessageBox.Show("移库单号不得为空!");
				this.txtMove.Focus();
				return false;
			}
			if(this.txtPay.Text=="")
			{
				MessageBox.Show("付款单号不得为空!");
				this.txtPay.Focus();
				return false;
			}
			if(this.txtSelling.Text=="")
			{
				MessageBox.Show("销售单号不得为空!");
				this.txtSelling.Focus();
				return false;
			}
			if(this.txtSellS.Text=="")
			{
				MessageBox.Show("销售订单号不得为空!");
				this.txtSellS.Focus();
				return false;
			}
			if(this.txtStock.Text=="")
			{
				MessageBox.Show("采购订单号不得为空!");
				this.txtStock.Focus();
				return false;
			}
			return true;

			
		}
		private bool _isModify=false;
		private void frmInitial_Load(object sender, System.EventArgs e)
		{
			string job="";
			try
			{
				this._sqlCon.Open();
				this._sqlCom.Parameters[0].Value=this._userID;
				job=(string)_sqlCom.ExecuteScalar();
				this._sqlAdap.Fill(this._dsOsINI1);

				
				if(job!="总经理"&&job!="系统管理员")
				{
					foreach (Control col in this.groupBox1.Controls)
					{
						if(col.GetType().ToString().IndexOf("TextBox")!=-1)
						{
							((TextBox)col).ReadOnly=true;
						}
					}
					foreach (Control col in this.groupBox2.Controls)
					 {
						 if(col.GetType().ToString().IndexOf("TextBox")!=-1)
						 {
							 ((TextBox)col).ReadOnly=true;
						 }
					 }
					
				}else
				{
					if(this._dsOsINI1.tblOsInit.Count!=0)
					{
						foreach (Control col in this.groupBox1.Controls)
						{
							if(col.GetType().ToString().IndexOf("TextBox")!=-1)
							{
								((TextBox)col).ReadOnly=false;
							}
						}
						foreach (Control col in this.groupBox2.Controls)
						{
							if(col.GetType().ToString().IndexOf("TextBox")!=-1)
							{
								((TextBox)col).ReadOnly=true;
							}
						}
						_isModify=true;
					}
					else
					{
						foreach (Control col in this.groupBox1.Controls)
						{
							if(col.GetType().ToString().IndexOf("TextBox")!=-1)
							{
								((TextBox)col).ReadOnly=false;
							}
						}
						foreach (Control col in this.groupBox2.Controls)
						{
							if(col.GetType().ToString().IndexOf("TextBox")!=-1)
							{
								((TextBox)col).ReadOnly=false;
							}
						}
						_isModify=false;
					}
				}
			}
			catch(SqlException ex)
			{
				MessageBox.Show("数据库操作错误!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}
			catch(Exception et)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。\n"+et.Message,"系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				this.Close();
			}
			finally
			{
				this._sqlCon.Close();
			}
			
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.Close();
			}
			catch(Exception et)
			{
				MessageBox.Show("系统发生一个异常的错误!请与管理员联系。","系统错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				this.Close();
			}
		}

		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -