/// <summary> /// event to delete the selected record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Delete_btn_Click(object sender, EventArgs e) { int selectedrowindex = Mold_dgv.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = Mold_dgv.Rows[selectedrowindex]; messageData = new MessageData("mmcc00004", Properties.Resources.mmcc00004, selectedRow.Cells["colMoldCode"].Value.ToString()); logger.Info(messageData); DialogResult dialogResult = popUpMessage.ConfirmationOkCancel(messageData, Text); if (dialogResult == DialogResult.OK) { MoldVo inVo = new MoldVo { MoldId = Convert.ToInt32(selectedRow.Cells["colMoldId"].Value), RegistrationDateTime = Convert.ToDateTime(DateTime.Now.ToString(UserData.GetUserData().DateTimeFormat)), RegistrationUserCode = UserData.GetUserData().UserCode, MoldCode = selectedRow.Cells["colMoldCode"].Value.ToString() }; try { MoldVo checkVo = CheckRelation(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00007", Properties.Resources.mmce00007, CAVITY.ToString()); popUpMessage.Information(messageData, Text); return; } MoldVo outVo = (MoldVo)base.InvokeCbm(new DeleteMoldMasterMntCbm(), inVo, false); if (outVo.AffectedCount > 0) { messageData = new MessageData("mmci00003", Properties.Resources.mmci00003, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (outVo.AffectedCount == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } } else if (dialogResult == DialogResult.Cancel) { //do something else } }
/// <summary> /// Fills all user records to gridview control /// </summary> private void GridBind(MoldVo conditionInVo) { Mold_dgv.DataSource = null; try { MoldVo outVo = (MoldVo)base.InvokeCbm(new GetMoldMasterMntCbm(), conditionInVo, false); Mold_dgv.AutoGenerateColumns = false; BindingSource bindingSource1 = new BindingSource(outVo.MoldListVo, null); if (bindingSource1.Count > 0) { Mold_dgv.DataSource = bindingSource1; } else { messageData = new MessageData("mmci00006", Properties.Resources.mmci00006, null); //"mold" logger.Info(messageData); popUpMessage.Information(messageData, Text); } Mold_dgv.ClearSelection(); Update_btn.Enabled = false; Delete_btn.Enabled = false; } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
/// <summary> /// selects user record for updation and show user form /// </summary> private void BindUpdateUserData() { int selectedrowindex = Mold_dgv.SelectedCells[0].RowIndex; MoldVo selectedMold = (MoldVo)Mold_dgv.Rows[selectedrowindex].DataBoundItem; AddMoldForm newAddForm = new AddMoldForm(); newAddForm.CreateForm(CommonConstants.MODE_UPDATE, selectedMold); newAddForm.ShowDialog(this); if (newAddForm.IntSuccess > 0) { messageData = new MessageData("mmci00002", Properties.Resources.mmci00002, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } else if (newAddForm.IntSuccess == 0) { messageData = new MessageData("mmci00007", Properties.Resources.mmci00007, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } }
/// <summary> /// For setting selected user record into respective controls(textbox and combobox) for update operation /// passing selected user data as parameter /// </summary> /// <param name="dgvMoldType"></param> private void LoadUserData(MoldVo dgvMoldType) { if (dgvMoldType != null) { this.MoldCode_txt.Text = dgvMoldType.MoldCode; this.MoldName_txt.Text = dgvMoldType.MoldName; this.MoldType_cmb.SelectedValue = dgvMoldType.MoldTypeId.ToString(); MoldVo conditionInVo = new MoldVo(); conditionInVo.MoldId = dgvMoldType.MoldId; MoldVo outVo = (MoldVo)base.InvokeCbm(new GetMoldMasterMntCbm(), conditionInVo, false); if (outVo.MoldListVo.Count > 0) { Weight_txt.Text = outVo.MoldListVo[0].Weight.ToString(); Width_txt.Text = outVo.MoldListVo[0].Width.ToString(); Height_txt.Text = outVo.MoldListVo[0].Height.ToString(); Depth_txt.Text = outVo.MoldListVo[0].Depth.ToString(); LifeShotCount_txt.Text = outVo.MoldListVo[0].LifeShotCount.ToString(); Comment_txt.Text = outVo.MoldListVo[0].Comment; ProductionDate_dtp.Text = outVo.MoldListVo[0].ProductionDate.ToString("yyyy-MM-dd"); } } }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { List <ValueObject> inList = ((ValueObjectList <ValueObject>)vo).GetList(); MoldVo moldInVo = (MoldVo)inList.FirstOrDefault(); ProcessWorkMoldVo processWorkMoldInVo = (ProcessWorkMoldVo)inList.Skip(1).FirstOrDefault(); MoldVo moldOutVo = (MoldVo)updateMoldMasterMntCbm.Execute(trxContext, moldInVo); if (moldOutVo.AffectedCount > 0) { processWorkMoldInVo.MoldId = moldInVo.MoldId; ProcessWorkMoldVo deleteInVo = new ProcessWorkMoldVo(); deleteInVo.MoldId = moldInVo.MoldId; ProcessWorkMoldVo deleteOutVo = (ProcessWorkMoldVo)deleteProcessWorkMoldMasterMntCbm.Execute(trxContext, deleteInVo); foreach (ProcessWorkMoldVo processid in processWorkMoldInVo.ProcessWorkMoldListVo) { processWorkMoldInVo.ProcessWorkId = processid.ProcessWorkId; ProcessWorkMoldVo ProcessWorkMoldoutVo = (ProcessWorkMoldVo)addProcessWorkMoldMasterMntCbm.Execute(trxContext, processWorkMoldInVo); } } return(moldOutVo); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoldDetailVo inVo = (MoldDetailVo)vo; MoldVo moldVo = new MoldVo(); moldVo.MoldCode = inVo.MoldCode; moldVo.MoldName = inVo.MoldName; moldVo.Weight = inVo.Weight; moldVo.Height = inVo.Height; moldVo.Depth = inVo.Depth; moldVo.Width = inVo.Width; moldVo.Comment = inVo.Comment; moldVo.LifeShotCount = inVo.LifeShotCount; moldVo.ProductionDate = inVo.ProductionDate; MoldVo moldOutVo = (MoldVo)addMoldMasterMntCbm.Execute(trxContext, moldVo); MoldDetailVo moldDetailOutVo = null; if (moldOutVo.MoldId > 0) { inVo.MoldId = moldOutVo.MoldId; moldDetailOutVo = (MoldDetailVo)addMoldDetailMasterMntCbm.Execute(trxContext, inVo); moldDetailOutVo.MoldId = moldOutVo.MoldId; } return(moldDetailOutVo); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoldDetailVo inVo = (MoldDetailVo)vo; MoldVo moldInVo = new MoldVo(); moldInVo.MoldId = inVo.MoldId; moldInVo.MoldCode = inVo.MoldCode; moldInVo.MoldName = inVo.MoldName; moldInVo.Weight = inVo.Weight; moldInVo.Height = inVo.Height; moldInVo.Depth = inVo.Depth; moldInVo.Width = inVo.Width; moldInVo.Comment = inVo.Comment; moldInVo.LifeShotCount = inVo.LifeShotCount; moldInVo.ProductionDate = inVo.ProductionDate; CbmController targetCbm = new UpdateMoldMasterMntCbm(); MoldVo moldOutVo = (MoldVo)targetCbm.Execute(trxContext, moldInVo); if (moldOutVo.AffectedCount > 0) { //MoldModelVo modetOutVo = (MoldModelVo)updateMoldModelCbm.Execute(trxContext, inVo); updateLocalItemDao.Execute(trxContext, vo); return(updateMolDetDao.Execute(trxContext, vo)); } return(null); }
public AddMoldForm CreateForm(string pmode, MoldVo dataItem = null) { mode = pmode; updateData = dataItem; return(new AddMoldForm()); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Update m_mold"); sqlQuery.Append(" Set "); sqlQuery.Append(" mold_name = :moldname, "); sqlQuery.Append(" mold_type_id = :moldtypeid, "); sqlQuery.Append(" width = :width ,"); sqlQuery.Append(" depth = :depth ,"); sqlQuery.Append(" height = :height ,"); sqlQuery.Append(" weight = :weight ,"); sqlQuery.Append(" production_date_time = :pdt ,"); sqlQuery.Append(" life_shot_count = :lfscount ,"); sqlQuery.Append(" comment = :comment"); sqlQuery.Append(" Where "); sqlQuery.Append(" mold_id = :moldid"); sqlQuery.Append(" and factory_cd = :faccd;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("moldid", inVo.MoldId); sqlParameter.AddParameterString("moldname", inVo.MoldName); sqlParameter.AddParameterInteger("moldtypeid", inVo.MoldTypeId); sqlParameter.AddParameter("width", inVo.Width); sqlParameter.AddParameter("depth", inVo.Depth); sqlParameter.AddParameter("height", inVo.Height); sqlParameter.AddParameter("weight", inVo.Weight); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.ProductionDate != System.DateTime.MinValue) { sqlParameter.AddParameterDateTime("pdt", inVo.ProductionDate); } else { sqlParameter.AddParameter("pdt", System.DBNull.Value); } sqlParameter.AddParameter("lfscount", inVo.LifeShotCount); sqlParameter.AddParameterString("comment", inVo.Comment); MoldVo outVo = new MoldVo { AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter) }; return(outVo); }
/// <summary> /// constructor for the form /// </summary> /// <param name="pmode"></param> /// <param name="dataItem"></param> public AddMoldNewForm(string pmode, MoldVo dataItem = null) { InitializeComponent(); mode = pmode; updateData = dataItem; if (string.Equals(mode, CommonConstants.MODE_UPDATE)) { this.Text = UpdateText_lbl.Text; } }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoldVo deleteOutVo = (MoldVo)deleteMoldMasterMntCbm.Execute(trxContext, vo); if (deleteOutVo.AffectedCount > 0) { ProcessWorkMoldVo inVo = new ProcessWorkMoldVo(); inVo.MoldId = ((MoldVo)vo).MoldId; ProcessWorkMoldVo deleteProcessWorkMoldOutVo = (ProcessWorkMoldVo)deleteProcessWorkMoldMasterMntCbm.Execute(trxContext, inVo); } return(deleteOutVo); }
/// <summary> /// checks duplicate mold Code /// </summary> /// <returns></returns> private MoldVo DuplicateCheck(MoldVo checkInVo) { MoldVo outVo = new MoldVo(); try { outVo = (MoldVo)base.InvokeCbm(new CheckMoldMasterMntCbm(), checkInVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
/// <summary> /// checks mold relation to other tables in DB /// </summary> /// <param name="moVo"></param> /// <returns></returns> private MoldVo CheckRelation(MoldVo moVo) { MoldVo outVo = new MoldVo(); try { outVo = (MoldVo)base.InvokeCbm(new CheckMoldRelationCbm(), moVo, false); } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } return(outVo); }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoldDetailVo outVo = (MoldDetailVo)deleteMoldDetailMasterMntCbm.Execute(trxContext, vo); if (outVo.AffectedCount > 0) { MoldDetailVo inVo = (MoldDetailVo)vo; MoldVo moldInVo = new MoldVo(); moldInVo.MoldId = inVo.MoldId; deleteMoldMasterMntCbm.Execute(trxContext, moldInVo); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("select count(cv.cavity_cd) as CavityCount from m_mold mo"); sqlQuery.Append(" inner join m_cavity cv on cv.mold_id = mo.mold_id"); sqlQuery.Append(" where mo.factory_cd = :faccd "); if (inVo.MoldCode != null) { sqlQuery.Append(" and UPPER(mold_cd) = UPPER(:moldcd) "); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); if (inVo.MoldCode != null) { sqlParameter.AddParameterString("moldcd", inVo.MoldCode); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); MoldVo outVo = new MoldVo(); while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32("0" + dataReader["CavityCount"]); } dataReader.Close(); return(outVo); }
/// <summary> /// Creates seacrh condition as per user inputs /// </summary> /// <returns>search condition</returns> private MoldVo FormConditionVo() { MoldVo inVo = new MoldVo(); if (MoldCode_txt.Text != string.Empty) { inVo.MoldCode = MoldCode_txt.Text; } if (MoldName_txt.Text != string.Empty) { inVo.MoldName = MoldName_txt.Text; } if (MoldType_cmb.SelectedIndex > -1) { inVo.MoldTypeId = Convert.ToInt32(MoldType_cmb.SelectedValue); } return(inVo); }
/// <summary> /// form country and factory data for combo /// </summary> private void FormDatatableFromVo() { moldDatatable = new DataTable(); moldDatatable.Columns.Add("id"); moldDatatable.Columns.Add("code"); try { MoldVo moldOutVo = (MoldVo)base.InvokeCbm(new GetMoldMasterMntCbm(), new MoldVo(), false); foreach (MoldVo mold in moldOutVo.MoldListVo) { moldDatatable.Rows.Add(mold.MoldId, mold.MoldCode); } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select Count(*) as MoldCount from m_mold "); sqlQuery.Append(" where 1 = 1 "); if (inVo.MoldCode != null) { sqlQuery.Append(" and UPPER(mold_cd) = UPPER(:moldcd) "); } //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (inVo.MoldCode != null) { sqlParameter.AddParameterString("moldcd", inVo.MoldCode); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); MoldVo outVo = new MoldVo(); while (dataReader.Read()) { outVo.AffectedCount = Convert.ToInt32(dataReader["MoldCount"]); } dataReader.Close(); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Delete From m_mold"); sqlQuery.Append(" Where "); sqlQuery.Append(" mold_id = :moldid "); sqlQuery.Append(" and factory_cd = :faccd ;"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterInteger("moldid", inVo.MoldId); sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); MoldVo outVo = new MoldVo {AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)}; return outVo; }
public ValueObject Execute(TransactionContext trxContext, ValueObject vo) { List <ValueObject> inList = ((ValueObjectList <ValueObject>)vo).GetList(); MoldVo moldInVo = (MoldVo)inList.FirstOrDefault(); ProcessWorkMoldVo processWorkMoldInVo = (ProcessWorkMoldVo)inList.Skip(1).FirstOrDefault(); MoldVo moldOutVo = (MoldVo)addGetMoldIdMasterMntCbm.Execute(trxContext, moldInVo); if (moldOutVo != null && moldOutVo.MoldId > 0) { processWorkMoldInVo.MoldId = moldOutVo.MoldId; foreach (ProcessWorkMoldVo processid in processWorkMoldInVo.ProcessWorkMoldListVo) { processWorkMoldInVo.ProcessWorkId = processid.ProcessWorkId; ProcessWorkMoldVo processWorkMoldoutVo = (ProcessWorkMoldVo)addProcessWorkMoldMasterMntCbm.Execute(trxContext, processWorkMoldInVo); } } return(moldOutVo); }
/// <summary> /// Upload mold master excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Upload_btn_Click(object sender, EventArgs e) { OpenFileDialog openDialog_dlg = new OpenFileDialog(); openDialog_dlg.Filter = "Excel Files(*.xls) |*.xls"; if (openDialog_dlg.ShowDialog() == DialogResult.OK) { this.StartProgress(Properties.Resources.mmci00009); try { excelUploadDt = new ExcelUpload().ReadExcel(openDialog_dlg.FileName, Properties.Settings.Default.EXCEL_SHEET_MOLD); } catch (Framework.ApplicationException exception) { this.CompleteProgress(); popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } MoldVo checkInVo = new MoldVo(); ProcessWorkMoldVo processWorkMoldInVo = new ProcessWorkMoldVo(); Mold_dgv.DataSource = null; excelUploadDt.Columns.Add("Remarks"); excelUploadDt.Columns.Add("Comment"); var sch = StringCheckHelper.GetInstance(); bool inputDataNG = false; foreach (DataRow row in excelUploadDt.Rows) { if (row["Comments"] != null && !string.IsNullOrWhiteSpace(row["Comments"].ToString())) { row["Comment"] = row["Comments"].ToString(); } if (row["MoldCode"] == null || string.IsNullOrWhiteSpace(row["MoldCode"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmce00011, MoldCode_lbl.Text); inputDataNG = true; continue; } if (!sch.IsASCII(row["MoldCode"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmci00017, MoldCode_lbl.Text); inputDataNG = true; continue; } var duplicates = excelUploadDt.AsEnumerable().GroupBy(r => r["MoldCode"]).Where(gr => gr.Count() > 1).ToList(); if (duplicates.Any() && duplicates.Select(dupl => dupl.Key).ToList().FirstOrDefault().ToString() == row["MoldCode"].ToString()) { row["Remarks"] = string.Format(Properties.Resources.mmce00009, MoldCode_lbl.Text + " : " + row["MoldCode"].ToString()); inputDataNG = true; continue; } if (row["MoldName"] == null || string.IsNullOrWhiteSpace(row["MoldName"].ToString())) { row["Remarks"] = string.Format(Properties.Resources.mmci00017, MoldName_lbl.Text); inputDataNG = true; continue; } checkInVo = new MoldVo(); processWorkMoldInVo = new ProcessWorkMoldVo(); checkInVo.MoldCode = row["MoldCode"].ToString(); checkInVo.MoldName = row["MoldName"].ToString(); if (!ValidateProcessWorkCodeInExcel(excelUploadDt, checkInVo.MoldCode)) { row["Remarks"] = string.Format(Properties.Resources.mmci00019); inputDataNG = true; continue; } MoldVo checkVo = DuplicateCheck(checkInVo); if (checkVo != null && checkVo.AffectedCount > 0) { row["Remarks"] = string.Format(Properties.Resources.mmce00012, MoldCode_lbl.Text + " : " + checkInVo.MoldCode); inputDataNG = true; continue; } } Mold_dgv.AutoGenerateColumns = false; isExcelUpload = true; Mold_dgv.Columns["colRemarks"].Visible = true; Mold_dgv.DataSource = excelUploadDt; if (inputDataNG) { Save_btn.Enabled = false; } else { Save_btn.Enabled = true; } this.CompleteProgress(); } }
private void Save_btn_Click(object sender, EventArgs e) { if (Mold_dgv.RowCount > 0 && Mold_dgv.Columns["colRemarks"].Visible == true) { if (processWorkList.Count == 0) { GetProcessWork(); } this.StartProgress(Properties.Resources.mmci00009); string previousMoldCode = string.Empty; int uploadedCount = 0; int insertedCount = 0; MoldVo checkInVo = new MoldVo(); ProcessWorkMoldVo processWorkMoldInVo = new ProcessWorkMoldVo(); decimal width = 0; decimal depth = 0; decimal height = 0; decimal weight = 0; DateTime productionDate; int lifeShotCount = 0; foreach (DataRow row in excelUploadDt.Rows) { if (!string.IsNullOrEmpty(row["MoldCode"].ToString()) && previousMoldCode != row["MoldCode"].ToString()) { checkInVo = new MoldVo(); processWorkMoldInVo = new ProcessWorkMoldVo(); checkInVo.MoldCode = row["MoldCode"].ToString(); checkInVo.MoldName = row["MoldName"].ToString(); if (row["MoldTypeCode"] != null && !string.IsNullOrWhiteSpace(row["MoldTypeCode"].ToString())) { checkInVo.MoldTypeCode = row["MoldTypeCode"].ToString(); } if (row["Width"] != null && !string.IsNullOrWhiteSpace(row["Width"].ToString()) && Decimal.TryParse(row["Width"].ToString(), out width)) { checkInVo.Width = width; } if (row["Depth"] != null && !string.IsNullOrWhiteSpace(row["Depth"].ToString()) && Decimal.TryParse(row["Depth"].ToString(), out depth)) { checkInVo.Depth = depth; } if (row["Height"] != null && !string.IsNullOrWhiteSpace(row["Height"].ToString()) && Decimal.TryParse(row["Height"].ToString(), out height)) { checkInVo.Height = height; } if (row["Weight"] != null && !string.IsNullOrWhiteSpace(row["Weight"].ToString()) && Decimal.TryParse(row["Weight"].ToString(), out weight)) { checkInVo.Weight = weight; } if (row["ProductionDate"] != null && !string.IsNullOrWhiteSpace(row["ProductionDate"].ToString()) && DateTime.TryParse(row["ProductionDate"].ToString(), out productionDate)) { checkInVo.ProductionDate = productionDate; } if (row["LifeShotCount"] != null && !string.IsNullOrWhiteSpace(row["LifeShotCount"].ToString()) && int.TryParse(row["LifeShotCount"].ToString(), out lifeShotCount)) { checkInVo.LifeShotCount = lifeShotCount; } if (row["Comments"] != null && !string.IsNullOrWhiteSpace(row["Comments"].ToString())) { checkInVo.Comment = row["Comments"].ToString(); } uploadedCount += 1; DataRow[] processWorkCodeList = excelUploadDt.Select("MoldCode = '" + checkInVo.MoldCode + "'"); foreach (DataRow item in processWorkCodeList) { ProcessWorkMoldVo addVo = new ProcessWorkMoldVo(); if (processWorkList.Where(t => t.ProcessWorkCode == item["ProcessWorkCode"].ToString()).FirstOrDefault() != null) { addVo.ProcessWorkId = processWorkList.Where(t => t.ProcessWorkCode == item["ProcessWorkCode"].ToString()).FirstOrDefault().ProcessWorkId; } processWorkMoldInVo.ProcessWorkMoldListVo.Add(addVo); } ValueObjectList <ValueObject> inVoList = new ValueObjectList <ValueObject>(); inVoList.add(checkInVo); inVoList.add(processWorkMoldInVo); MoldVo outVo = null; try { //outVo = (MoldVo)base.InvokeCbm(new AddMoldMasterMntAndProcessworkCbm(), inVoList, false); } catch (Framework.ApplicationException exception) { this.CompleteProgress(); popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } if (outVo != null && outVo.AffectedCount > 0) { insertedCount += outVo.AffectedCount; } } previousMoldCode = row["MoldCode"].ToString(); } this.CompleteProgress(); if (insertedCount > 0 && uploadedCount > 0 && insertedCount == uploadedCount) { messageData = new MessageData("mmci00010", Properties.Resources.mmci00010, null); logger.Info(messageData); popUpMessage.Information(messageData, Text); GridBind(FormConditionVo()); } } }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Select md.mold_id, md.mold_cd, md.mold_name, mt.mold_type_id, mt.mold_type_cd, "); sqlQuery.Append(" md.width , md.depth , md.height , md.weight , "); sqlQuery.Append(" md.production_date_time , md.life_shot_count, "); sqlQuery.Append(" md.comment "); sqlQuery.Append(" from m_mold md "); sqlQuery.Append("left join m_mold_type mt on md.mold_type_id = mt.mold_type_id "); sqlQuery.Append(" where md.factory_cd = :faccd "); if (inVo.MoldId > 0) { sqlQuery.Append(" and md.mold_id = :moldid "); } if (inVo.MoldCode != null) { sqlQuery.Append(" and md.mold_cd like :moldcd "); } if (inVo.MoldName != null) { sqlQuery.Append(" and md.mold_name like :moldname "); } if (inVo.MoldTypeId != 0) { sqlQuery.Append(" and mt.mold_type_id = :moldtypeid "); } sqlQuery.Append(" order by md.mold_cd"); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); if (!string.IsNullOrEmpty(inVo.FactoryCode)) { sqlParameter.AddParameterString("faccd", inVo.FactoryCode); } else { sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode); } if (inVo.MoldId != 0) { sqlParameter.AddParameterInteger("moldid", inVo.MoldId); } if (inVo.MoldCode != null) { sqlParameter.AddParameterString("moldcd", inVo.MoldCode + "%"); } if (inVo.MoldName != null) { sqlParameter.AddParameterString("moldname", inVo.MoldName + "%"); } if (inVo.MoldTypeId != 0) { sqlParameter.AddParameterInteger("moldtypeid", inVo.MoldTypeId); } //execute SQL IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter); MoldVo outVo = new MoldVo(); while (dataReader.Read()) { MoldVo currOutVo = new MoldVo(); currOutVo.MoldId = ConvertDBNull <Int32>(dataReader, "mold_id"); currOutVo.MoldCode = ConvertDBNull <string>(dataReader, "mold_cd"); currOutVo.MoldName = ConvertDBNull <string>(dataReader, "mold_name"); currOutVo.MoldTypeId = ConvertDBNull <Int32>(dataReader, "mold_type_id"); currOutVo.MoldTypeCode = ConvertDBNull <string>(dataReader, "mold_type_cd"); currOutVo.Width = ConvertDBNull <decimal>(dataReader, "width"); currOutVo.Depth = ConvertDBNull <decimal>(dataReader, "depth"); currOutVo.Height = ConvertDBNull <decimal>(dataReader, "height"); currOutVo.Weight = ConvertDBNull <decimal>(dataReader, "weight"); currOutVo.ProductionDate = ConvertDBNull <DateTime>(dataReader, "production_date_time"); currOutVo.Comment = ConvertDBNull <string>(dataReader, "comment"); currOutVo.LifeShotCount = ConvertDBNull <Int32>(dataReader, "life_shot_count"); outVo.MoldListVo.Add(currOutVo); } dataReader.Close(); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject arg) { MoldVo inVo = (MoldVo)arg; StringBuilder sqlQuery = new StringBuilder(); sqlQuery.Append("Insert into m_mold"); sqlQuery.Append(" ( "); sqlQuery.Append(" mold_cd, "); sqlQuery.Append(" mold_name, "); sqlQuery.Append(" mold_type_id, "); sqlQuery.Append(" width , depth , height , weight , "); sqlQuery.Append(" production_date_time , life_shot_count, "); sqlQuery.Append(" comment, "); sqlQuery.Append(" registration_user_cd, "); sqlQuery.Append(" registration_date_time, "); sqlQuery.Append(" factory_cd "); sqlQuery.Append(" ) "); sqlQuery.Append("VALUES "); sqlQuery.Append(" ( "); sqlQuery.Append(" :moldcd ,"); sqlQuery.Append(" :moldname ,"); sqlQuery.Append(" :moldtypeid ,"); sqlQuery.Append(" :width , :depth , :height , :weight, "); sqlQuery.Append(" :pdt, :lfscount ,"); sqlQuery.Append(" :comment ,"); sqlQuery.Append(" :registrationusercode ,"); sqlQuery.Append(" now() ,"); sqlQuery.Append(" :factorycode "); sqlQuery.Append(" ) "); sqlQuery.Append(" RETURNING mold_id "); //create command DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString()); //create parameter DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList(); sqlParameter.AddParameterString("moldcd", inVo.MoldCode); sqlParameter.AddParameterString("moldname", inVo.MoldName); sqlParameter.AddParameterInteger("moldtypeid", inVo.MoldTypeId); sqlParameter.AddParameter("width", inVo.Width); sqlParameter.AddParameter("depth", inVo.Depth); sqlParameter.AddParameter("height", inVo.Height); sqlParameter.AddParameter("weight", inVo.Weight); if (inVo.ProductionDate != System.DateTime.MinValue) { sqlParameter.AddParameterDateTime("pdt", inVo.ProductionDate); } else { sqlParameter.AddParameter("pdt", System.DBNull.Value); } sqlParameter.AddParameter("lfscount", inVo.LifeShotCount); sqlParameter.AddParameter("comment", inVo.Comment); sqlParameter.AddParameterString("registrationusercode", UserData.GetUserData().UserCode); sqlParameter.AddParameterDateTime("registrationdatetime", trxContext.ProcessingDBDateTime); sqlParameter.AddParameterString("factorycode", UserData.GetUserData().FactoryCode); MoldVo outVo = new MoldVo();// {AffectedCount = sqlCommandAdapter.ExecuteNonQuery(sqlParameter)}; outVo.MoldId = (int?)sqlCommandAdapter.ExecuteScalar(sqlParameter) ?? 0; if (outVo != null && outVo.MoldId > 0) { outVo.AffectedCount = 1; } return(outVo); }
/// <summary> /// update data to db /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Ok_btn_Click(object sender, EventArgs e) { if (CheckMandatory()) { ValueObjectList <ValueObject> inVoList = new ValueObjectList <ValueObject>(); var sch = StringCheckHelper.GetInstance(); if (!sch.IsASCII(MoldCode_txt.Text)) { messageData = new MessageData("mmce00003", Properties.Resources.mmce00003); logger.Info(messageData); popUpMessage.ConfirmationOkCancel(messageData, Text); MoldCode_txt.Focus(); return; } MoldVo inVo = new MoldVo(); inVo.MoldCode = MoldCode_txt.Text.Trim(); inVo.MoldName = MoldName_txt.Text.Trim(); inVo.MoldTypeId = Convert.ToInt32(MoldType_cmb.SelectedValue); if (!string.IsNullOrEmpty(Weight_txt.Text)) { inVo.Weight = Convert.ToDecimal(Weight_txt.Text); } if (!string.IsNullOrEmpty(Height_txt.Text)) { inVo.Height = Convert.ToDecimal(Height_txt.Text); } if (!string.IsNullOrEmpty(Width_txt.Text)) { inVo.Width = Convert.ToDecimal(Width_txt.Text); } if (!string.IsNullOrEmpty(Depth_txt.Text)) { inVo.Depth = Convert.ToDecimal(Depth_txt.Text); } if (!string.IsNullOrWhiteSpace(ProductionDate_dtp.Text)) { inVo.ProductionDate = Convert.ToDateTime(ProductionDate_dtp.Value); } inVo.Comment = Comment_txt.Text; if (!string.IsNullOrEmpty(LifeShotCount_txt.Text)) { inVo.LifeShotCount = Convert.ToInt32(LifeShotCount_txt.Text); } if (string.Equals(mode, CommonConstants.MODE_ADD)) { MoldVo checkVo = DuplicateCheck(inVo); if (checkVo != null && checkVo.AffectedCount > 0) { messageData = new MessageData("mmce00001", Properties.Resources.mmce00001, MoldCode_lbl.Text + " : " + MoldCode_txt.Text); logger.Info(messageData); popUpMessage.ApplicationError(messageData, Text); return; } } try { this.StartProgress(Properties.Resources.mmci00009); if (string.Equals(mode, CommonConstants.MODE_ADD)) { inVoList.add(inVo); inVoList.add(GetSelectedProcessWork()); MoldVo outVo = (MoldVo)base.InvokeCbm(new AddMoldMasterMntNewCbm(), inVoList, false); IntSuccess = outVo.AffectedCount; } else if (mode.Equals(CommonConstants.MODE_UPDATE)) { inVo.MoldId = updateData.MoldId; inVoList.add(inVo); inVoList.add(GetSelectedProcessWork()); MoldVo outVo = (MoldVo)base.InvokeCbm(new UpdateMoldMasterMntNewCbm(), inVoList, false); IntSuccess = outVo.AffectedCount; } } catch (Framework.ApplicationException exception) { popUpMessage.ApplicationError(exception.GetMessageData(), Text); logger.Error(exception.GetMessageData()); return; } finally { this.CompleteProgress(); } if ((IntSuccess > 0) || (IntSuccess == 0)) { this.Close(); } } }