/// <summary> /// 导入规格 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_GG_Click(object sender, EventArgs e) { DataTable dt = OpenExcelFile(this.txtUrl.Text, "sheet1"); StringBuilder strLog = new StringBuilder(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { DataTable dtMain = Bll_TPB_SLABWH.GetList_id(dt.Rows[i]["仓库编码"].ToString(), dt.Rows[i]["仓库描述"].ToString()).Tables[0]; if (dtMain.Rows.Count > 0) { string s_id = dtMain.Rows[0]["C_ID"].ToString(); if (!string.IsNullOrEmpty(dt.Rows[i][0].ToString().Trim())) { if (i > 0) { if (dt.Rows[i]["区域编码"].ToString().Trim() == dt.Rows[i - 1]["区域编码"].ToString().Trim()) { continue; } } try { Mod_TPB_SLABWH_AREA model = new Mod_TPB_SLABWH_AREA(); model.C_SLABWH_ID = s_id; model.C_SLABWH_AREA_CODE = dt.Rows[i]["区域编码"].ToString(); model.C_SLABWH_AREA_NAME = dt.Rows[i]["区域描述"].ToString(); model.C_EMP_ID = "222"; bool res = Bll_TPB_SLABWH_AREA.Add(model); if (!res) { strLog.Append("添加失败"); } } catch { strLog.Append("添加失败"); } } } } strLog.Append("导入完成!"); rtxt_Log.Text = strLog.ToString(); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "导入库位");//添加操作日志 } }
private void FrmPB_GPKQY_EDIT_Load(object sender, EventArgs e) { strMenuName = RV.UI.UserInfo.menuName; Mod_TPB_SLABWH_AREA mod = Bll_TPB_SLABWH_AREA.GetModel(c_id); txt_QYBH.Text = mod.C_SLABWH_AREA_CODE; txt_QYMS.Text = mod.C_SLABWH_AREA_NAME; txt_Remark.Text = mod.C_REMARK; }
/// <summary> /// 删除选中的区域信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_stop_area_Click(object sender, EventArgs e) { try { if (DialogResult.No == MessageBox.Show("是否确认删除选中的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } int selectedNum = this.gv_slab_area.SelectedRowsCount; int commitNum = 0; //删除记录数量 int cannotNum = 0; //不能删除记录数量 int failtNum = 0; //删除失败数量 int[] rownumber = this.gv_slab_area.GetSelectedRows(); //获取选中行号数组; for (int i = 0; i < rownumber.Length; i++) { int selectedHandle = rownumber[i]; string strID = this.gv_slab_area.GetRowCellValue(selectedHandle, "C_ID").ToString(); //判断该仓库的区域是否已经全部删除 bool hasNoStopLoc = bll_TPB_SLABWH_LOC.GetListByArea(strID, 1).Tables[0].Rows.Count == 0 ? true : false; if (hasNoStopLoc) { Mod_TPB_SLABWH_AREA model = bll_TPB_SLABWH_AREA.GetModel(strID); model.N_STATUS = 0; model.C_EMP_ID = RV.UI.UserInfo.userID; model.D_MOD_DT = RV.UI.ServerTime.timeNow(); model.D_END_DATE = RV.UI.ServerTime.timeNow(); bool update = bll_TPB_SLABWH_AREA.Update(model); if (update) { commitNum = commitNum + 1; } else { failtNum = failtNum + 1; } } else { MessageBox.Show("请先删除该区域下的所有库位!"); cannotNum = cannotNum + 1; } } MessageBox.Show("选择" + selectedNum.ToString() + "条记录,删除" + commitNum.ToString() + "条记录!"); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "删除区域信息");//添加操作日志 btn_query_area_Click(null, null); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_SLABWH_AREA model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TPB_SLABWH_AREA set "); strSql.Append("C_SLABWH_ID=:C_SLABWH_ID,"); strSql.Append("C_SLABWH_AREA_CODE=:C_SLABWH_AREA_CODE,"); strSql.Append("C_SLABWH_AREA_NAME=:C_SLABWH_AREA_NAME,"); strSql.Append("D_START_DATE=:D_START_DATE,"); strSql.Append("D_END_DATE=:D_END_DATE,"); strSql.Append("N_STATUS=:N_STATUS,"); strSql.Append("C_REMARK=:C_REMARK,"); strSql.Append("C_EMP_ID=:C_EMP_ID,"); strSql.Append("D_MOD_DT=:D_MOD_DT"); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_SLABWH_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_SLABWH_AREA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_SLABWH_AREA_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":D_START_DATE", OracleDbType.Date), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":N_STATUS", OracleDbType.Decimal, 1), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 200), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100), new OracleParameter(":D_MOD_DT", OracleDbType.Date), new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_SLABWH_ID; parameters[1].Value = model.C_SLABWH_AREA_CODE; parameters[2].Value = model.C_SLABWH_AREA_NAME; parameters[3].Value = model.D_START_DATE; parameters[4].Value = model.D_END_DATE; parameters[5].Value = model.N_STATUS; parameters[6].Value = model.C_REMARK; parameters[7].Value = model.C_EMP_ID; parameters[8].Value = model.D_MOD_DT; parameters[9].Value = model.C_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_SLABWH_AREA DataRowToModel(DataRow row) { Mod_TPB_SLABWH_AREA model = new Mod_TPB_SLABWH_AREA(); if (row != null) { if (row["C_ID"] != null) { model.C_ID = row["C_ID"].ToString(); } if (row["C_SLABWH_ID"] != null) { model.C_SLABWH_ID = row["C_SLABWH_ID"].ToString(); } if (row["C_SLABWH_AREA_CODE"] != null) { model.C_SLABWH_AREA_CODE = row["C_SLABWH_AREA_CODE"].ToString(); } if (row["C_SLABWH_AREA_NAME"] != null) { model.C_SLABWH_AREA_NAME = row["C_SLABWH_AREA_NAME"].ToString(); } if (row["D_START_DATE"] != null && row["D_START_DATE"].ToString() != "") { model.D_START_DATE = DateTime.Parse(row["D_START_DATE"].ToString()); } if (row["D_END_DATE"] != null && row["D_END_DATE"].ToString() != "") { model.D_END_DATE = DateTime.Parse(row["D_END_DATE"].ToString()); } if (row["N_STATUS"] != null && row["N_STATUS"].ToString() != "") { model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString()); } if (row["C_REMARK"] != null) { model.C_REMARK = row["C_REMARK"].ToString(); } if (row["C_EMP_ID"] != null) { model.C_EMP_ID = row["C_EMP_ID"].ToString(); } if (row["D_MOD_DT"] != null && row["D_MOD_DT"].ToString() != "") { model.D_MOD_DT = DateTime.Parse(row["D_MOD_DT"].ToString()); } } return(model); }
private void btn_Save_Click(object sender, EventArgs e) { try { Mod_TPB_SLABWH_AREA mod = Bll_TPB_SLABWH_AREA.GetModel(c_id); mod.C_SLABWH_AREA_CODE = txt_QYBH.Text; mod.C_SLABWH_AREA_NAME = txt_QYMS.Text; mod.C_REMARK = txt_Remark.Text; mod.C_EMP_ID = RV.UI.UserInfo.UserID; mod.D_MOD_DT = RV.UI.ServerTime.timeNow(); Bll_TPB_SLABWH_AREA.Update(mod); MessageBox.Show("保存成功!"); Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "修改钢坯库区域");//添加操作日志 this.DialogResult = DialogResult.Cancel; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 焦点行变化时加载区域信息 /// </summary> public void BindFoucedQY() { int selectedHandle = this.gv_slab_area.FocusedRowHandle;//获取焦点行索引 if (selectedHandle < 0) { btn_reset_area_Click(null, null); //加载仓库库位信息 BindXCKW(this.lbl_Area_ID.Text, 1); return; } this.lbl_Area_ID.Text = this.gv_slab_area.GetRowCellValue(selectedHandle, "C_ID").ToString();//获取焦点行主键 //根据主键得到仓库对象,并在界面赋值 Mod_TPB_SLABWH_AREA model = bll_TPB_SLABWH_AREA.GetModel(this.lbl_Area_ID.Text); this.txt_Area_Code.Text = model.C_SLABWH_AREA_CODE; this.txt_Area_Name.Text = model.C_SLABWH_AREA_NAME; this.txt_remark_area.Text = model.C_REMARK; //加载仓库库位信息 BindXCKW(this.lbl_Area_ID.Text, 1); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_SLABWH_AREA model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TPB_SLABWH_AREA("); strSql.Append("C_SLABWH_ID,C_SLABWH_AREA_CODE,C_SLABWH_AREA_NAME,D_END_DATE,C_REMARK,C_EMP_ID)"); strSql.Append(" values ("); strSql.Append(":C_SLABWH_ID,:C_SLABWH_AREA_CODE,:C_SLABWH_AREA_NAME,:D_END_DATE,:C_REMARK,:C_EMP_ID)"); OracleParameter[] parameters = { new OracleParameter(":C_SLABWH_ID", OracleDbType.Varchar2, 100), new OracleParameter(":C_SLABWH_AREA_CODE", OracleDbType.Varchar2, 100), new OracleParameter(":C_SLABWH_AREA_NAME", OracleDbType.Varchar2, 100), new OracleParameter(":D_END_DATE", OracleDbType.Date), new OracleParameter(":C_REMARK", OracleDbType.Varchar2, 200), new OracleParameter(":C_EMP_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = model.C_SLABWH_ID; parameters[1].Value = model.C_SLABWH_AREA_CODE; parameters[2].Value = model.C_SLABWH_AREA_NAME; parameters[3].Value = model.D_END_DATE; parameters[4].Value = model.C_REMARK; parameters[5].Value = model.C_EMP_ID; int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TPB_SLABWH_AREA GetModel(string C_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select C_ID,C_SLABWH_ID,C_SLABWH_AREA_CODE,C_SLABWH_AREA_NAME,D_START_DATE,D_END_DATE,N_STATUS,C_REMARK,C_EMP_ID,D_MOD_DT from TPB_SLABWH_AREA "); strSql.Append(" where C_ID=:C_ID "); OracleParameter[] parameters = { new OracleParameter(":C_ID", OracleDbType.Varchar2, 100) }; parameters[0].Value = C_ID; Mod_TPB_SLABWH_AREA model = new Mod_TPB_SLABWH_AREA(); DataSet ds = DbHelperOra.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 保存区域信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_save_area_Click(object sender, EventArgs e) { try { string strWHID = ""; int selectedHandle = this.gv_slab_wh.FocusedRowHandle;//获取焦点行索引 if (selectedHandle >= 0) { strWHID = this.gv_slab_wh.GetRowCellValue(selectedHandle, "C_ID").ToString();//获取焦点行主键 } else { MessageBox.Show("请先选择对应的仓库信息!"); return; } if (this.txt_Area_Code.Text.Trim().Length == 0) { MessageBox.Show("请输入区域编码!"); this.txt_Area_Code.Focus(); return; } if (this.txt_Area_Name.Text.Trim().Length == 0) { MessageBox.Show("请输入区域描述!"); this.txt_Area_Name.Focus(); return; } if (this.lbl_Area_ID.Text == "") { if (DialogResult.No == MessageBox.Show("是否确认添加区域信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } Mod_TPB_SLABWH_AREA model = new Mod_TPB_SLABWH_AREA(); model.C_SLABWH_ID = strWHID; model.C_SLABWH_AREA_CODE = this.txt_Area_Code.Text.Trim(); model.C_SLABWH_AREA_NAME = this.txt_Area_Name.Text.Trim(); model.C_REMARK = this.txt_remark_area.Text.Trim(); model.C_EMP_ID = RV.UI.UserInfo.userID; #region 检测是否重复添加 System.Collections.Hashtable ht = new System.Collections.Hashtable(); ht.Add("C_SLABWH_ID", model.C_SLABWH_ID); ht.Add("C_SLABWH_AREA_CODE", model.C_SLABWH_AREA_CODE); ht.Add("N_STATUS", 1); if (Common.CheckRepeat.CheckTable("TPB_SLABWH_AREA", ht) > 0) { MessageBox.Show("已存在该区域编码!"); } else { bool res = bll_TPB_SLABWH_AREA.Add(model); if (res) { Common.UserLog.AddLog(strMenuName, this.Name, this.Text, "添加区域信息");//添加操作日志 MessageBox.Show("添加成功!"); BindXCQU(strWHID, 1); //重新加载区域信息 btn_reset_area_Click(null, null); //清空控件 } } #endregion } else { if (DialogResult.No == MessageBox.Show("是否确认编辑区域信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)) { return; } Mod_TPB_SLABWH_AREA model = bll_TPB_SLABWH_AREA.GetModel(this.lbl_Area_ID.Text); model.C_SLABWH_AREA_CODE = this.txt_Area_Code.Text.Trim(); model.C_SLABWH_AREA_NAME = this.txt_Area_Name.Text.Trim(); model.C_REMARK = this.txt_remark_area.Text.Trim(); model.C_EMP_ID = RV.UI.UserInfo.userID; model.D_MOD_DT = RV.UI.ServerTime.timeNow(); bool res = bll_TPB_SLABWH_AREA.Update(model); if (res) { MessageBox.Show("编辑成功!"); BindXCQU(strWHID, 1); //重新加载区域信息 btn_reset_area_Click(null, null); //清空控件 } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Mod_TPB_SLABWH_AREA model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Mod_TPB_SLABWH_AREA model) { return(dal.Add(model)); }