private void metroButton2_Click(object sender, EventArgs e) { FormHelpers.CursorWait(true); try { if (mgridRights.SelectedRows.Count < 1) { throw new Exception("No selected User Rights!"); } else { var usrgrpcode = BPSUtilitiesV1.NZ(mgridRights.SelectedRows[0].Cells["colUserGroupCode"].Value, "").ToString(); var menuid = Convert.ToInt32(BPSUtilitiesV1.NZ(mgridRights.SelectedRows[0].Cells["colMenuID"].Value, 0)); if (usrgrpcode != "" && menuid != 0) { Removeright(usrgrpcode, menuid); } } } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }
public Boolean Save(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials wipmat in record.WIPMaterials) { db.WIPMaterialsList.Add(wipmat); db.SaveChanges(); } } db.WIPList.Add(record); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Delete(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { var existrecord = GetByID(record.YEARUSED, record.ItemNo, record.PartCode); if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials mat in record.WIPMaterials) { db.WIPMaterialsList.Remove(mat); db.SaveChanges(); } } db.WIPList.Remove(existrecord); db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { tbl_000_H_PART existcom = new tbl_000_H_PART(); existcom = combal.GetAll().Where(m => m.YEARUSED == UserSettings.LogInYear && m.PartNo == mtxtPartNo.Text).FirstOrDefault(); if (existcom == null) { com.YEARUSED = UserSettings.LogInYear; com.PartNo = mtxtPartNo.Text; com.CreatedDate = DateTime.Now; com.CreatedBy = UserSettings.Username; com.IsCopied = false; com.CopyDate = DateTime.Now; com.IsImported = false; com.ImportDate = DateTime.Now; com.ImportBy = UserSettings.Username; } com.PartName = mtxtPartName.Text; com.WholeQty = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtWholeQty.Text, 0)); com.WholeUnit = mtxtWholeUnit.Text; com.ConversionQty = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtConversionQty.Text, 0)); com.ConversionUnit = mtxtConversionUnit.Text; com.WholePrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtWholePrice.Text, 0)); com.ConversionPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtConversionPrice.Text, 0)); com.PreviousPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPreviousPrice.Text, 0)); com.IsLocked = mcbLocked.Checked; com.ExpDate = DateTime.Now; com.UpdatedDate = DateTime.Now; com.UpdatedBy = UserSettings.Username; } else { com = combal.GetByID(yearused, partno); if (com != null) { mtxtPartNo.Text = com.PartNo; mtxtPartName.Text = com.PartName; mcbLocked.Checked = com.IsLocked; mtxtPreviousPrice.Text = String.Format("{0:n4}", com.PreviousPrice); mtxtWholePrice.Text = String.Format("{0:n4}", com.WholePrice); mtxtWholeQty.Text = String.Format("{0:n2}", com.WholeQty); mtxtWholeUnit.Text = com.WholeUnit; mtxtConversionPrice.Text = String.Format("{0:n4}", com.ConversionPrice); mtxtConversionQty.Text = String.Format("{0:n2}", com.ConversionQty); mtxtConversionUnit.Text = com.ConversionUnit; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
public Boolean Update(tbl_100_WIP record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record.WIPMaterials, "").ToString() != "") { foreach (tbl_100_WIP_Materials wipmat in record.WIPMaterials) { if (wipmat.state == "update") { db.Entry(wipmat).State = EntityState.Modified; db.SaveChanges(); } else if (wipmat.state == "add") { db.WIPMaterialsList.Add(wipmat); db.SaveChanges(); } } } dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { mt.YEARUSED = UserSettings.LogInYear; mt.PartNo = mtxtPartNo.Text; mt.PartName = mtxtPartName.Text; mt.Usage = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtUsage.Text, 0)); mt.Process = mtxtProcess.Text; mt.Vendor = mtxtVendor.Text; } else { mt = mtbal.GetByID(UserSettings.LogInYear, pno); if (mt != null) { mtxtPartNo.Text = mt.PartNo; mtxtPartName.Text = mt.PartName; mtxtUsage.Text = mt.Usage.ToString(); mtxtProcess.Text = mt.Process; mtxtVendor.Text = mt.Vendor; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { cat.CATCODE = mtxtCategoryCode.Text; cat.CATDESC = mtxtCategoryDesc.Text; cat.RATECONVERSION = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPhp.Text, 0)); cat.FIXEDCHARGELABOR = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFCLabor.Text, 0)); cat.FIXEDCHARGEFO = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFCFOverhead.Text, 0)); cat.PRODALLOWANCETIME = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPTAllowance.Text, 0)); cat.FIXEDRATELOSS = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFRLMProcess.Text, 0)); cat.FIXEDRATEPROFIT = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFPRate.Text, 0)); cat.YENRATECONVERSION = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtYen.Text, 0)); cat.FIXEDRATEDEPNMOLD = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFCDMold.Text, 0)); cat.FIXEDRATEDEPNFILM = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtFCDFilm.Text, 0)); cat.OTHERPROCESSCOST = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtOPCost.Text, 0)); cat.YEARUSED = UserSettings.LogInYear; cat.MoldSetup = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtMoldSetup.Text, 0)); cat.LotSize = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtLotSize.Text, 0)); cat.IsDependent = mcbDependent.Checked; cat.IsActive = mcbActive.Checked; } else { cat = catbal.GetByID(CategoryCode, YearUsed); if (cat != null) { mtxtCategoryCode.Text = cat.CATCODE; mtxtCategoryDesc.Text = cat.CATDESC; mtxtPhp.Text = cat.RATECONVERSION.ToString(); mtxtFCLabor.Text = cat.FIXEDCHARGELABOR.ToString(); mtxtFCFOverhead.Text = cat.FIXEDCHARGEFO.ToString(); mtxtPTAllowance.Text = cat.PRODALLOWANCETIME.ToString(); mtxtFRLMProcess.Text = cat.FIXEDRATELOSS.ToString(); mtxtFPRate.Text = cat.FIXEDRATEPROFIT.ToString(); mtxtYen.Text = cat.YENRATECONVERSION.ToString(); mtxtFCDMold.Text = cat.FIXEDRATEDEPNMOLD.ToString(); mtxtFCDFilm.Text = cat.FIXEDRATEDEPNFILM.ToString(); mtxtOPCost.Text = cat.OTHERPROCESSCOST.ToString(); mtxtMoldSetup.Text = cat.MoldSetup.ToString(); mtxtLotSize.Text = cat.LotSize.ToString(); mcbDependent.Checked = cat.IsDependent; mcbActive.Checked = cat.IsActive; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
private void mtxtCatCode_TextChanged(object sender, EventArgs e) { string selectedcatcode = BPSUtilitiesV1.NZ(mtxtCatCode.Text, "").ToString(); cat = catbal.GetByID(selectedcatcode, selyear); if (cat != null) { mtxtCatDesc.Text = BPSUtilitiesV1.NZ(cat.CATDESC, "").ToString(); } }
private void ItemDesc() { string selecteditemno = BPSUtilitiesV1.NZ(mtxtItemNo.Text, "").ToString(); itm = itmbal.GetByID(UserSettings.LogInYear, selecteditemno); if (itm != null) { mtxtItemDesc.Text = BPSUtilitiesV1.NZ(itm.Description, "").ToString(); } }
private void mtxtItemNo_TextChanged(object sender, EventArgs e) { string selecteditemno = BPSUtilitiesV1.NZ(mtxtItemNo.Text, "").ToString(); itm = itmbal.GetByID(selyear, selecteditemno); if (itm != null) { mtxtItemDesc.Text = BPSUtilitiesV1.NZ(itm.Description, "").ToString(); } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { usr.UserID = usr.UserID; usr.Username = mtxtUsername.Text; usr.Password = mtxtPassword.Text; usr.FullName = mtxtFullName.Text; usr.UserGroupCode = mcboUserGroupCode.SelectedValue.ToString(); usr.UserGroupDesc = mcboUserGroupCode.Text; usr.SectionCode = BPSUtilitiesV1.NZ(mcboSectionCode.SelectedValue, "").ToString(); usr.SectionDesc = BPSUtilitiesV1.NZ(mcboSectionCode.Text, "").ToString(); usr.AccessLevel = mtxtAccessLevel.Text; usr.IsActive = mcbActive.Checked; if (ofdImage.FileName != "") { usr.UserPhoto = BPSolutionsTools.BPSUtilitiesV1.ImageToByte(Image.FromFile(ofdImage.FileName)); } } else { usr = userbal.GetByUsername(username); if (usr != null) { mtxtUsername.Text = usr.Username; mtxtPassword.Text = usr.Password; mtxtConfirmPassword.Text = usr.Password; mtxtFullName.Text = usr.FullName; mcboUserGroupCode.SelectedValue = usr.UserGroupCode; mcboSectionCode.SelectedValue = usr.SectionCode; //mcboSectionCode.Text=usr.SectionDesc; mtxtAccessLevel.Text = usr.AccessLevel; mcbActive.Checked = usr.IsActive; if (usr.UserPhoto != null) { picUser.BackgroundImage = BPSolutionsTools.BPSUtilitiesV1.BytesToImage(usr.UserPhoto); } } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } finally { } }
public void Init_Form() { FormHelpers.FormatForm(this.Controls); minid = Convert.ToInt64(BPSUtilitiesV1.NZ(signabal.GetAll().Select(s => s.RecID).FirstOrDefault(), 1)); GetList(); MyState = FormState.View; mbtnModify.Text = "Modify"; LockFields(true); err.BlinkRate = 7; }
private void KeyColumnLocker() { for (int i = 0; i < mgridList.RowCount; i++) { var yearused = mgridList.Rows[i].Cells["colYEARUSED"].Value; if (Convert.ToInt32(BPSUtilitiesV1.NZ(yearused, 0)) != 0) { mgridList.Rows[i].Cells["colSubProcessCode"].ReadOnly = true; } } }
private void FilltxtAutoComplete() { selyear = Convert.ToInt32(BPSUtilitiesV1.NZ(mcboYear.SelectedValue, 0)); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); var source = itmbal.GetItemNos(selyear); foreach (string i in source) { collection.Add(i); } mtxtItemNo.AutoCompleteMode = AutoCompleteMode.Suggest; mtxtItemNo.AutoCompleteSource = AutoCompleteSource.CustomSource; mtxtItemNo.AutoCompleteCustomSource = collection; }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { tbl_000_H_ASSY existassy = new tbl_000_H_ASSY(); existassy = assybal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && w.PartNo == mtxtPartNo.Text).FirstOrDefault(); if (existassy == null) { assy.CreatedDate = DateTime.Now; assy.CreatedBy = UserSettings.Username; assy.IsCopied = false; assy.CopyDate = DateTime.Now; assy.IsImported = false; assy.ImportDate = DateTime.Now; assy.ImportBy = UserSettings.Username; } assy.YEARUSED = UserSettings.LogInYear; assy.PartNo = mtxtPartNo.Text; assy.PartName = mtxtPartName.Text; assy.HC = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtHC.Text, 0)); assy.Qty = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtQty.Text, 0)); assy.RATEPERHOUR = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtRatePerHour.Text, 0)); assy.IsLocked = mcbLocked.Checked; assy.UpdatedDate = DateTime.Now; assy.UpdatedBy = UserSettings.Username; } else { assy = assybal.GetByID(yearused, partno); if (assy != null) { mtxtPartNo.Text = assy.PartNo; mtxtPartName.Text = assy.PartName; mtxtHC.Text = ((double)assy.HC).ToString(); mtxtQty.Text = ((double)assy.Qty).ToString(); mtxtRatePerHour.Text = assy.RATEPERHOUR.ToString(); mcbLocked.Checked = assy.IsLocked; assy.UpdatedDate = DateTime.Now; assy.UpdatedBy = UserSettings.Username; } } } catch (Exception ex) { throw ex; } }
private void GetComponents() { try { FormHelpers.CursorWait(true); var itemno = BPSUtilitiesV1.NZ(mtxtItemNo.Text, "").ToString(); var partscode = BPSUtilitiesV1.NZ(mtxtPartCode.Text, "").ToString(); ListHelper.FillMetroCombo(mcboCatCode, catbal.GetAll().Select(i => new { i.CATCODE, i.CATDESC }). Where(w => w.CATCODE == "BULK").Distinct().ToList(), "CATCODE", "CATCODE"); var catcode = BPSUtilitiesV1.NZ(mcboCatCode.SelectedValue, "").ToString(); item = itembal.GetWithCat(UserSettings.LogInYear, itemno, catcode); GetRefCompDetails(); if (item != null && item.itemCom.Count > 0) { if (partscode != "") { itemcom = item.itemCom.Where(w => w.PartNo == partscode).OrderBy(o => o.ItemAddress).FirstOrDefault(); if (itemcom != null) { var sourceTable = item.itemCom.Where(w => w.ItemAddress.StartsWith(itemcom.ItemAddress) && w.ItemAddress != itemcom.ItemAddress).ToList(); using (var reader = ObjectReader.Create(sourceTable, "DocID", "MatCode", "MatDescription", "ItemUsage", "UnitPrice", "Amount", "Address")) { dt.Load(reader); mgridMatList.DataSource = dt; } } } } } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }
private void AssignMain() { wip = wipbal.GetByRecID(recid); if (wip == null) { wip = new tbl_100_WIP(); wip.YEARUSED = UserSettings.LogInYear; wip.ItemNo = mtxtItemNo.Text; wip.PartCode = mtxtPartCode.Text; GetRefCompDetails(); wip.PartName = mtxtPartName.Text; wip.CatCode = BPSUtilitiesV1.NZ(mcboCatCode.SelectedValue, "").ToString(); wip.MaterialLabor = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSubTotal.Text, 0)); wip.ProfitRate = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtProfitRate.Text, 0)); wip.SellingPrice = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSellingPrice.Text, 0)); wip.ForexRate = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtForex.Text, 0)); wip.CreatedBy = UserSettings.Username; wip.UpdatedBy = UserSettings.Username; wip.Remarks = mtxtRemarks.Text; } }
public static void UniqueRow(DataGridView dgv, string cellname) { try { string initialnamevalue = dgv.Rows[0].Cells[cellname].Value.ToString(); for (int i = 1; i < dgv.Rows.Count; i++) { if (BPSUtilitiesV1.NZ(dgv.Rows[i].Cells[cellname].Value, "").ToString() == initialnamevalue) { dgv.Rows.RemoveAt(i); } else { initialnamevalue = BPSUtilitiesV1.NZ(dgv.Rows[i].Cells[cellname].Value, "").ToString(); } } } catch { } }
private void AssignRecord() { try { AssignMain(); for (int i = 0; i < mgridMatList.RowCount; i++) { if (mgridMatList.Rows[i].IsNewRow) { continue; } var wmrecid = Convert.ToInt64(BPSUtilitiesV1.NZ(mgridMatList.Rows[i].Cells["colDocID"].Value.ToString(), 0)); var wipmat = wipmatbal.GetByRecID(wmrecid); if (wipmat == null) { wipmat = new tbl_100_WIP_Materials(); wipmat.state = "add"; } else { wipmat.state = "update"; } wipmat.YEARUSED = UserSettings.LogInYear; wipmat.ItemNo = mtxtItemNo.Text; wipmat.PartNo = mtxtPartCode.Text; wipmat.MatCode = mgridMatList.Rows[i].Cells["colMoldNo"].Value.ToString(); wipmat.MatDescroption = mgridMatList.Rows[i].Cells["colMatDescription"].Value.ToString(); wipmat.Usage = Convert.ToDecimal(mgridMatList.Rows[i].Cells["colUsage"].Value); wipmat.UnitType = mgridMatList.Rows[i].Cells["colUnitType"].Value.ToString(); wipmat.UnitPrice = Convert.ToDecimal(mgridMatList.Rows[i].Cells["colUnitPrice"].Value); wipmat.Amount = Convert.ToDecimal(mgridMatList.Rows[i].Cells["colAmount"].Value); wipmat.Address = mgridMatList.Rows[i].Cells["colAddress"].Value.ToString(); } } catch (Exception ex) { throw ex; } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { fxsp.RecType = mcboType.SelectedItem.ToString(); fxsp.EffectiveDate = Convert.ToDateTime(mdtpEffectiveDate.Value.Date); fxsp.Rate = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtRate.Text, 0)); //For Testing fxsp.YearUsed = UserSettings.LogInYear; fxsp.CreatedBy = UserSettings.Username; fxsp.CreatedDate = DateTime.Now; fxsp.UpdatedBy = UserSettings.Username; fxsp.UpdatedDate = DateTime.Now; //end } else { fxsp = fxspbal.GetByID(RecType, Convert.ToDateTime(EffectiveDate)); if (fxsp != null) { mcboType.SelectedItem = fxsp.RecType; mdtpEffectiveDate.Value = fxsp.EffectiveDate; mtxtRate.Text = fxsp.Rate.ToString(); } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
public Boolean Save_List(List <tbl_000_H_PART> record_list) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record_list, "").ToString() != null) { foreach (tbl_000_H_PART c in record_list) { db.ComponentList.Add(c); db.SaveChanges(); } } dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
private void ContinueCopy() { try { FormHelpers.CursorWait(true); List <tbl_000_H_ITEM> write_list_itm; selyear = Convert.ToInt32(mcboYear.SelectedValue.ToString()); if (!mcbOverWrite.Checked) { msg = "This process will copy previous components from the selected year to the current logged in year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Copy case YearsOf.Components: Save_com(false); break; #endregion #region Tabulation to Copy case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: Save_pi(false); break; case MaintainanceTableSub.VacuumPlating: Save_vp(false); break; case MaintainanceTableSub.Assembly: Save_assy(false); break; } break; #endregion #region Process to Copy case YearsOf.ProcessSetup: Save_proc(false); break; #endregion #region Items to Copy case YearsOf.Items: write_list_itm = new List <tbl_000_H_ITEM>(); var currentyear_list_itm = itmbal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_H_ITEM i in currentyear_list_itm) { write_list_itm.Add(itmbal.GetAll().Where(w => w.YEARUSED == selyear && w.ItemNo == i.ItemNo).FirstOrDefault()); } foreach (tbl_000_H_ITEM i in write_list_itm) { if (i != null) { itmlist.RemoveAll(r => r.ItemNo == i.ItemNo); } } Save_item(); break; #endregion } } } else { msg = "This process will remove the existing components and replace it with the selected year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Copy with Overwrite case YearsOf.Components: Save_com(true); break; #endregion #region Tabulation to Copy with Overwrite case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: Save_pi(true); break; case MaintainanceTableSub.VacuumPlating: Save_vp(true); break; case MaintainanceTableSub.Assembly: Save_assy(true); break; } break; #endregion #region Process to Copy with Overwrite case YearsOf.ProcessSetup: Save_proc(true); break; #endregion #region Items to Copy with Overwrite case YearsOf.Items: write_list_itm = new List <tbl_000_H_ITEM>(); foreach (tbl_000_H_ITEM i in itmlist) { write_list_itm.Add(itmbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && w.ItemNo == i.ItemNo).FirstOrDefault()); } AssignSubItems(write_list_itm); if (BPSUtilitiesV1.NZ(write_list_itm, "").ToString() != "") { foreach (tbl_000_H_ITEM i in write_list_itm) { if (i != null) { todelete_item.Add(i); } } var tmptodelete_item = todelete_item; itmbal.Delete_List(todelete_item); //AssignSubItems(itmlist); DeleteSub(todelete_item); Save_item(); } break; #endregion } } } this.Close(); } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }
private void mbtnGenerate_Click(object sender, EventArgs e) { var msg_succ = "Generating Successful!"; var msg_failed = "No Data Generated!"; if (MessageHelpers.ShowQuestion("Generate Report?") == System.Windows.Forms.DialogResult.Yes) { try { FormHelpers.CursorWait(true); if (rptdetails.SP_GeneratePriceListComparison(Convert.ToInt32(mcbofrstYear.SelectedValue), Convert.ToInt32(mcboscndYear.SelectedValue), BPSUtilitiesV1.NZ(mcboCategory.SelectedValue, "").ToString()).Rows.Count == 0) { throw new Exception(msg_failed); } else { MessageHelpers.ShowInfo(msg_succ); } } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } } }
private void PreviewComparison(string strRptName) { try { FormHelpers.CursorWait(true); frm_ReportViewer frv = new frm_ReportViewer(); frv.report = new ReportTable(); frv.report.ReportName = strRptName; frv.report.ReportPath = ObjectFinder.ReportPath; frv.report.SourceTable = rptdetails.SP_GeneratePriceListComparison(Convert.ToInt32(mcbofrstYear.SelectedValue), Convert.ToInt32(mcboscndYear.SelectedValue), BPSUtilitiesV1.NZ(mcboCategory.SelectedValue, "").ToString()); if (frv.report.SourceTable == null || frv.report.SourceTable.Rows.Count == 0) { throw new Exception("Report no Data"); } frv.Text = "Price List Comparison Report"; frv.StartPosition = FormStartPosition.CenterScreen; frv.Show(); } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { string apprtag = "APPRD"; string preptag = "PREPRD"; string revitag = "REVWD"; signalist = new List <tbl_SIGNATORY>(); //Approved By signa = new tbl_SIGNATORY(); signa.RecID = minid; signa.SignName = BPSUtilitiesV1.NZ(mtxtApprName1.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtApprPosition1.Text, "").ToString(); signa.SignFor = apprtag; signalist.Add(signa); signa = new tbl_SIGNATORY(); signa.RecID = minid + 1; signa.SignName = BPSUtilitiesV1.NZ(mtxtApprName2.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtApprPosition2.Text, "").ToString(); signa.SignFor = apprtag; signalist.Add(signa); //Prepared By signa = new tbl_SIGNATORY(); signa.RecID = minid + 2; signa.SignName = BPSUtilitiesV1.NZ(mtxtPrepName1.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtPrepPosition1.Text, "").ToString(); signa.SignFor = preptag; signalist.Add(signa); signa = new tbl_SIGNATORY(); signa.RecID = minid + 3; signa.SignName = BPSUtilitiesV1.NZ(mtxtPrepName2.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtPrepPosition2.Text, "").ToString(); signa.SignFor = preptag; signalist.Add(signa); //Reviewed By signa = new tbl_SIGNATORY(); signa.RecID = minid + 4; signa.SignName = BPSUtilitiesV1.NZ(mtxtReviName1.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtReviPosition1.Text, "").ToString(); signa.SignFor = revitag; signalist.Add(signa); signa = new tbl_SIGNATORY(); signa.RecID = minid + 5; signa.SignName = BPSUtilitiesV1.NZ(mtxtReviName2.Text, "").ToString(); signa.SignPosition = BPSUtilitiesV1.NZ(mtxtReviPosition2.Text, "").ToString(); signa.SignFor = revitag; signalist.Add(signa); foreach (tbl_SIGNATORY s in signalist) { s.ReportName = this.Text; s.UpdatedBy = UserSettings.Username; s.UpdatedDate = DateTime.Now; } } } catch (Exception ex) { throw ex; } }
private void GetExclData(string FilePath) { try { using (FileStream stream = File.Open(FilePath, FileMode.Open, FileAccess.Read)) { reader = ExcelReaderFactory.CreateReader(stream); DataSet dirty_result = reader.AsDataSet(); DataSet result = reader.AsDataSet( new ExcelDataSetConfiguration { ConfigureDataTable = _ => new ExcelDataTableConfiguration { UseHeaderRow = true, ReadHeaderRow = rowReader => // skip 3 rows { rowReader.Read(); rowReader.Read(); rowReader.Read(); } } } ); if (result.Tables.Count > 0) { dttemp = new DataTable(); dttemp = dirty_result.Tables[0]; tmpdatalist = new List <tbl_tmp_H_ITEM_PART>(); List <tbl_tmp_H_ITEM_PART> tmpdatalist_cleaned = new List <tbl_tmp_H_ITEM_PART>(); tbl_tmp_H_ITEM_PART tmpdata = new tbl_tmp_H_ITEM_PART(); tmpdatalist = result.Tables[0].AsEnumerable().Select(r => new tbl_tmp_H_ITEM_PART { ItemAddress = BPSUtilitiesV1.NZ(r.Field <object>("ADDRESS"), "").ToString(), PartNo = BPSUtilitiesV1.NZ(r.Field <object>("CODE"), "").ToString(), PartName = BPSUtilitiesV1.NZ(r.Field <object>("PARTS NAME"), "").ToString(), ItemUsage = Usage(BPSUtilitiesV1.NZ(r.Field <object>("USAGE"), "1").ToString()), Process = BPSUtilitiesV1.NZ(r.Field <object>("PROCESS"), "").ToString(), ItemVendor = BPSUtilitiesV1.NZ(r.Field <object>("VENDOR"), "").ToString(), Bagging = BPSUtilitiesV1.NZ(r.Field <object>("PARTS NAME"), "").ToString() }).ToList(); if (BPSolutionsTools.BPSUtilitiesV1.NZ(dttemp.Rows[1][6], "").ToString() != "") { tmpdata.ItemAddress = ""; tmpdata.PartNo = dttemp.Rows[0][1].ToString(); tmpdata.PartName = "FINAL PROCESS"; tmpdata.ItemUsage = 1; tmpdata.Process = "_FP"; tmpdata.ItemVendor = ""; tmpdata.Bagging = ""; tmpdatalist_cleaned.Add(tmpdata); } foreach (tbl_tmp_H_ITEM_PART tc in tmpdatalist) { string strend = "REVISED PORTION"; if (tc.PartNo == strend || tc.PartName == strend || tc.Process == strend) { break; } if (tc.PartNo == null || tc.PartNo == "") { continue; } if (tc.ItemAddress.ToUpper() == "Y") { continue; } if (tc.ItemAddress == null || tc.ItemAddress == "") { continue; } tc.Bagging = Bagging(tc.ItemAddress); tmpdatalist_cleaned.Add(tc); } if (tmpdatalist_cleaned.Count == 0) { throw new Exception("No Data Found!"); } else { tmpcombal.Save(tmpdatalist_cleaned); } } } } catch (Exception ex) { throw ex; } }
private void AssignRecord(Boolean IsSave) { try { if (IsSave) { tbl_000_H_PI existpi = new tbl_000_H_PI(); existpi = pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && w.MoldNo == mtxtMoldNo.Text).FirstOrDefault(); if (existpi == null) { pi.YEARUSED = UserSettings.LogInYear; pi.CreatedDate = DateTime.Now; pi.CreatedBy = UserSettings.Username; pi.IsCopied = false; pi.CopyDate = DateTime.Now; pi.IsImported = false; pi.ImportDate = DateTime.Now; pi.ImportBy = UserSettings.Username; } pi.MoldNo = mtxtMoldNo.Text; pi.MoldName = mtxtMoldName.Text; pi.Oz = mtxtOz.Text; pi.Cavity = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtCavity.Text, 0)); pi.SPH = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtSPH.Text, 0)); pi.PPH = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPPH.Text, 0)); pi.Cavity = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtCavity.Text, 0)); pi.MolSetUpTime = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtMoldSetupTime.Text, 0)); pi.Usage = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtUsage.Text, 0)); pi.PurgePerG = Convert.ToDecimal(BPSUtilitiesV1.NZ(mtxtPPG.Text, 0)); pi.IsLocked = mcbLocked.Checked; pi.UpdatedDate = DateTime.Now; pi.UpdatedBy = UserSettings.Username; } else { pi = pibal.GetByID(yearused, moldno); if (pi != null) { mtxtMoldNo.Text = pi.MoldNo; mtxtMoldName.Text = pi.MoldName; mtxtOz.Text = pi.Oz; mtxtPPG.Text = pi.PurgePerG.ToString(); mtxtSPH.Text = Convert.ToInt32(pi.SPH).ToString(); mtxtCavity.Text = Convert.ToInt32(pi.Cavity).ToString(); mtxtPPH.Text = Convert.ToInt32(pi.PPH).ToString(); mtxtMoldSetupTime.Text = pi.MolSetUpTime.ToString(); mtxtUsage.Text = Convert.ToInt32(pi.Usage).ToString(); mcbLocked.Checked = pi.IsLocked; pi.UpdatedDate = DateTime.Now; pi.UpdatedBy = UserSettings.Username; } else { throw new Exception("Record doesn't exist!"); } } } catch (Exception ex) { throw ex; } }
private void Import() { List <tbl_000_H_PART> write_list_com; List <tbl_000_H_PI> write_list_pi; List <tbl_000_H_VP> write_list_vp; List <tbl_000_H_ASSY> write_list_assy; List <tbl_000_PROCESS> write_list_proc; try { GetExclData(mtxtFilePath.Text); if (!mcbOverWrite.Checked) { msg = "This process will import previous components from the selected year to the current logged in year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Import case YearsOf.Components: write_list_com = new List <tbl_000_H_PART>(); var currentyear_list_com = combal.GetByYear(UserSettings.LogInYear).ToList(); //Matching by 'PartNo' or 'PartName' foreach (tbl_000_H_PART c in currentyear_list_com) { write_list_com.Add(combal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == c.PartNo || w.PartName == c.PartName)).FirstOrDefault()); } //Remove columns from excell if it exists in current year foreach (tbl_000_H_PART c in write_list_com) { if (c != null) { comlist.RemoveAll(r => r.PartNo == c.PartNo || r.PartName == c.PartName); } } //Fill some Columns and Save them Save_com(); break; #endregion #region Tabulation to Import case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: write_list_pi = new List <tbl_000_H_PI>(); var currentyear_list_pi = pibal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_H_PI p in currentyear_list_pi) { write_list_pi.Add(pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.MoldNo == p.MoldNo || w.MoldName == p.MoldName)).FirstOrDefault()); } foreach (tbl_000_H_PI p in write_list_pi) { if (p != null) { pilist.RemoveAll(r => r.MoldNo == p.MoldNo || r.MoldName == p.MoldName); } } Save_pi(); break; case MaintainanceTableSub.VacuumPlating: write_list_vp = new List <tbl_000_H_VP>(); var currentyear_list_vp = vpbal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_H_VP v in currentyear_list_vp) { write_list_vp.Add(vpbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == v.PartNo || w.PartName == v.PartName)).FirstOrDefault()); } foreach (tbl_000_H_VP v in write_list_vp) { if (v != null) { vplist.RemoveAll(r => r.PartNo == v.PartNo || r.PartName == v.PartName); } } Save_vp(); break; case MaintainanceTableSub.Assembly: write_list_assy = new List <tbl_000_H_ASSY>(); var currentyear_list_assy = assybal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_H_ASSY a in currentyear_list_assy) { write_list_assy.Add(assybal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == a.PartNo || w.PartName == a.PartName)).FirstOrDefault()); } foreach (tbl_000_H_ASSY a in write_list_assy) { if (a != null) { assylist.RemoveAll(r => r.PartNo == a.PartNo || r.PartName == a.PartName); } } Save_assy(); break; } break; #endregion #region Process to Import case YearsOf.ProcessSetup: write_list_proc = new List <tbl_000_PROCESS>(); var currentyear_list_proc = procbal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_PROCESS p in currentyear_list_proc) { write_list_proc.Add(procbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.SubProcessCode == p.SubProcessCode || w.ItemDescription == p.ItemDescription)).FirstOrDefault()); } foreach (tbl_000_PROCESS p in write_list_proc) { if (p != null) { proclist.RemoveAll(r => r.SubProcessCode == p.SubProcessCode || r.ItemDescription == p.ItemDescription); } } Save_proc(); break; #endregion } } } else { msg = "This process will remove the existing components and replace it with the selected year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Import with Overwrite case YearsOf.Components: write_list_com = new List <tbl_000_H_PART>(); //Matching by 'PartNo' or 'PartName' foreach (tbl_000_H_PART c in comlist) { write_list_com.Add(combal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == c.PartNo || w.PartName == c.PartName)).FirstOrDefault()); } //Delete the records to be Overwritten if (BPSUtilitiesV1.NZ(write_list_com, "").ToString() != "") { foreach (tbl_000_H_PART c in write_list_com) { if (c != null) { combal.Delete(c); } } } //Fill some Columns and Save them Save_com(); break; #endregion #region Tabulation to import with Overwrite case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: write_list_pi = new List <tbl_000_H_PI>(); foreach (tbl_000_H_PI p in pilist) { write_list_pi.Add(pibal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.MoldNo == p.MoldNo || w.MoldName == p.MoldName)).FirstOrDefault()); } if (BPSUtilitiesV1.NZ(write_list_pi, "").ToString() != "") { foreach (tbl_000_H_PI p in write_list_pi) { if (p != null) { pibal.Delete(p); } } } Save_pi(); break; case MaintainanceTableSub.VacuumPlating: write_list_vp = new List <tbl_000_H_VP>(); foreach (tbl_000_H_VP v in vplist) { write_list_vp.Add(vpbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == v.PartNo || w.PartName == v.PartName)).FirstOrDefault()); } if (BPSUtilitiesV1.NZ(write_list_vp, "").ToString() != "") { foreach (tbl_000_H_VP v in write_list_vp) { if (v != null) { vpbal.Delete(v); } } } Save_vp(); break; case MaintainanceTableSub.Assembly: write_list_assy = new List <tbl_000_H_ASSY>(); foreach (tbl_000_H_ASSY a in assylist) { write_list_assy.Add(assybal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.PartNo == a.PartNo || w.PartName == a.PartName)).FirstOrDefault()); } if (BPSUtilitiesV1.NZ(write_list_assy, "").ToString() != "") { foreach (tbl_000_H_ASSY a in write_list_assy) { if (a != null) { assybal.Delete(a); } } } Save_assy(); break; } break; #endregion #region Process to Import with Overwrite case YearsOf.ProcessSetup: write_list_proc = new List <tbl_000_PROCESS>(); List <tbl_000_PROCESS> todelete_proc = new List <tbl_000_PROCESS>(); foreach (tbl_000_PROCESS p in proclist) { write_list_proc.Add(procbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && (w.SubProcessCode == p.SubProcessCode || w.ItemDescription == p.ItemDescription)).FirstOrDefault()); } if (BPSUtilitiesV1.NZ(write_list_proc, "").ToString() != "") { foreach (tbl_000_PROCESS p in write_list_proc) { if (p != null) { todelete_proc.Add(p); } } procbal.Delete(todelete_proc); } Save_proc(); break; #endregion } } } this.Close(); } catch (Exception ex) { throw ex; } }
public Boolean Save_List(List <tbl_000_H_ITEM> record_list) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { foreach (tbl_000_H_ITEM record in record_list) { if (BPSUtilitiesV1.NZ(record.itemCom, "").ToString() != "") { foreach (tbl_000_H_ITEM_PART item in record.itemCom) { db.ItemPartList.Add(item); db.SaveChanges(); } } if (BPSUtilitiesV1.NZ(record.itemPI, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION item in record.itemPI) { db.ItemTabulationPIList.Add(item); db.SaveChanges(); } } if (BPSUtilitiesV1.NZ(record.itemVP, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION_VP item in record.itemVP) { db.ItemTabulationVPList.Add(item); db.SaveChanges(); } } if (BPSUtilitiesV1.NZ(record.itemAssy, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION_ASSY item in record.itemAssy) { db.ItemTabulationAssyList.Add(item); db.SaveChanges(); } } if (BPSUtilitiesV1.NZ(record.itemMPT, "").ToString() != "") { foreach (tbl_000_H_ITEM_MPT item in record.itemMPT) { db.ItemMPTList.Add(item); db.SaveChanges(); } } if (BPSUtilitiesV1.NZ(record.itemFDC, "").ToString() != "") { foreach (tbl_000_H_ITEM_FDC item in record.itemFDC) { db.ItemFDCList.Add(item); db.SaveChanges(); } } db.ItemList.Add(record); } db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }
public Boolean Update(tbl_000_H_ITEM record) { using (var dbContextTransaction = db.Database.BeginTransaction()) { try { if (BPSUtilitiesV1.NZ(record.itemCom, "").ToString() != "") { foreach (tbl_000_H_ITEM_PART item in record.itemCom) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemPartList.Add(item); db.SaveChanges(); } } } if (BPSUtilitiesV1.NZ(record.itemPI, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION item in record.itemPI) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemTabulationPIList.Add(item); db.SaveChanges(); } } } if (BPSUtilitiesV1.NZ(record.itemVP, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION_VP item in record.itemVP) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemTabulationVPList.Add(item); db.SaveChanges(); } } } if (BPSUtilitiesV1.NZ(record.itemAssy, "").ToString() != "") { foreach (tbl_000_H_ITEM_TABULATION_ASSY item in record.itemAssy) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemTabulationAssyList.Add(item); db.SaveChanges(); } } } if (BPSUtilitiesV1.NZ(record.itemMPT, "").ToString() != "") { foreach (tbl_000_H_ITEM_MPT item in record.itemMPT) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemMPTList.Add(item); db.SaveChanges(); } } } if (BPSUtilitiesV1.NZ(record.itemFDC, "").ToString() != "") { foreach (tbl_000_H_ITEM_FDC item in record.itemFDC) { if (item.state == "update") { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } else if (item.state == "add") { db.ItemFDCList.Add(item); db.SaveChanges(); } } } db.Entry(record).State = EntityState.Modified; db.SaveChanges(); dbContextTransaction.Commit(); return(true); } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } }