/// <summary> /// 更新一条数据 /// </summary> public bool Update(Library.Model.Employee model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Employee set "); strSql.Append("F_Name=@F_Name,"); strSql.Append("F_Mobile=@F_Mobile,"); strSql.Append("F_IsDelete=@F_IsDelete"); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_Name", SqlDbType.VarChar, 50), new SqlParameter("@F_Mobile", SqlDbType.VarChar, 50), new SqlParameter("@F_IsDelete", SqlDbType.Int, 4), new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.F_Name; parameters[1].Value = model.F_Mobile; parameters[2].Value = model.F_IsDelete; parameters[3].Value = model.F_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Library.Model.Employee model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Employee("); strSql.Append("F_Name,F_Mobile,F_IsDelete)"); strSql.Append(" values ("); strSql.Append("@F_Name,@F_Mobile,@F_IsDelete)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@F_Name", SqlDbType.VarChar, 50), new SqlParameter("@F_Mobile", SqlDbType.VarChar, 50), new SqlParameter("@F_IsDelete", SqlDbType.Int, 4) }; parameters[0].Value = model.F_Name; parameters[1].Value = model.F_Mobile; parameters[2].Value = model.F_IsDelete; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { DataRow row = this.GridView.GetFocusedDataRow(); if (row != null) { if (MessageBox.Show("是否确认删除?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { int id = int.Parse(row["F_ID"].ToString()); Library.Model.Employee model = Library.Controller.SystemManager.Instance.Services.EmployeeService.GetModel(id); model.F_IsDelete = 1; Library.Controller.SystemManager.Instance.Services.EmployeeService.Update(model); BandGridData(); } } else { MessageBox.Show("请选择一行数据!"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.Employee DataRowToModel(DataRow row) { Library.Model.Employee model = new Library.Model.Employee(); if (row != null) { if (row["F_ID"] != null && row["F_ID"].ToString() != "") { model.F_ID = int.Parse(row["F_ID"].ToString()); } if (row["F_Name"] != null) { model.F_Name = row["F_Name"].ToString(); } if (row["F_Mobile"] != null) { model.F_Mobile = row["F_Mobile"].ToString(); } if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "") { model.F_IsDelete = int.Parse(row["F_IsDelete"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.Employee GetModel(int F_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_ID,F_Name,F_Mobile,F_IsDelete from T_Employee "); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = F_ID; Library.Model.Employee model = new Library.Model.Employee(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
internal void LoadData(System.Data.DataRow row) { if (row["F_ApplyAmount"] != null) { // " " + txtDate.Text = DateTime.Parse(row["F_ApplyDate"].ToString()).Year + " 年 " + DateTime.Parse(row["F_ApplyDate"].ToString()).Month + " 月 " + DateTime.Parse(row["F_ApplyDate"].ToString()).Day + " 日"; txtBigName.Text = MoneyToUpper(row["F_ApplyAmount"].ToString()); string money = double.Parse(row["F_ApplyAmount"].ToString()).ToString(); string[] moneys = money.Split('.'); Char[] m1 = moneys[0].ToCharArray(); if (m1.Length - 1 >= 0) { txtmoney1.Text = m1[m1.Length - 1].ToString(); } if (m1.Length - 2 >= 0) { txtmoney2.Text = m1[m1.Length - 2].ToString(); } if (m1.Length - 3 >= 0) { txtmoney3.Text = m1[m1.Length - 3].ToString(); } if (m1.Length - 4 >= 0) { txtmoney4.Text = m1[m1.Length - 4].ToString(); } if (m1.Length - 5 >= 0) { txtmoney5.Text = m1[m1.Length - 5].ToString(); } if (m1.Length - 6 >= 0) { txtmoney6.Text = m1[m1.Length - 6].ToString(); } if (moneys.Length >= 2 && !string.IsNullOrEmpty(moneys[1])) { Char[] m2 = moneys[1].ToCharArray(); if (m2.Length >= 1) { txtmoney01.Text = m2[0].ToString(); } if (m2.Length >= 2) { txtmoney02.Text = m2[1].ToString(); } } } //if (row["F_Name"] != null) //{ // txtdepartment.Text = MoneyToUpper(row["F_Name"].ToString()); //} if (row["F_OperatorID"] != null) { Library.Model.Employee pmodel = SystemManager.Instance.Services.EmployeeService.GetModel(int.Parse(row["F_OperatorID"].ToString())); txtuser.Text = pmodel.F_Name; last5name.Text = pmodel.F_Name; } last3name.Text = SystemManager.Instance.Services.EmployeeService.GetRoleToUserName(ConfigurationManager.AppSettings["总经理"]); last4name.Text = SystemManager.Instance.Services.EmployeeService.GetRoleToUserName(ConfigurationManager.AppSettings["财务"]); DataTable list = SystemManager.Instance.Services.ProjectCostService.GetAppList(row["F_ID"].ToString()); Show_Loaded(list); }