public void Initialized() { Functions.QueryCmbCustomerList(db, ref lueSearchCustomer); string customerCode = lueSearchCustomer.Properties.GetKeyValueByDisplayText(lueSearchCustomer.Text).ToString(); Functions.QueryCmbUserCodeData(db, ref lueSearchPOType, lueSearchPOType.Tag.ToString(), "", true); string pOType = lueSearchPOType.Properties.GetKeyValueByDisplayText(lueSearchPOType.Text).ToString(); Functions.QueryCmbAvailablePOList(db, ref lueSearchPO, customerCode, pOType, "", true); barEditCopies.EditValue = 1; dtSearchDateFrom.EditValue = Convert.ToDateTime(db.fn_ServerDateTime()).AddDays(-7); dtSearchDateFrom.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; dtSearchDateFrom.Properties.Mask.EditMask = "MM/dd/yyyy"; dtSearchDateTo.EditValue = (DateTime?)db.fn_ServerDateTime(); dtSearchDateFrom.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateFrom.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; dtSearchDateTo.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateTo.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchCustomer.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchCustomer.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchPO.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchPO.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; txtSearchBoxNo.Properties.AppearanceFocused.BackColor = Color.Yellow; txtSearchBoxNo.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; }
public Boolean DeleteData() { try { Cursor.Current = Cursors.WaitCursor; intPOHeaderID = Convert.ToInt16(txtPOHeaderID.Text); if (intPOHeaderID <= 0) { //XtraMessageBox.Show("Please, input P/O Number first.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); //txtPONumber.Focus(); return(false); } DialogResult result = XtraMessageBox.Show("Do you want to delete P/O Data?", "Question!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) { return(false); } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); var qryPODetail = from pod in db.PODetails where pod.POHeaderID == intPOHeaderID select pod; foreach (var dtl in qryPODetail) { db.PODetails.DeleteOnSubmit(dtl); } var qryPOHeader = from poh in db.POHeaders where poh.POHeaderID == intPOHeaderID select poh; foreach (var dtl in qryPOHeader) { db.POHeaders.DeleteOnSubmit(dtl); } db.SubmitChanges(); } scope.Complete(); } MessageBox.Show("Delete Completed!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Exception Error!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SearchData(); Cursor.Current = Cursors.Default; } return(false); }
public void Initialized() { //Search Group Functions.QueryCheckCmbCustomerList(db, ref lueSearchCustomer, false); Functions.QueryCheckCmbPOTypeList(db, ref lueSearchPOType, false); //string customerCode = lueSearchCustomer.Properties.GetKeyValueByDisplayText(lueSearchCustomer.Text).ToString(); dtSearchDateFrom.EditValue = (DateTime?)db.fn_ServerDateTime(); //dtSearchDateFrom.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; //dtSearchDateFrom.Properties.Mask.EditMask = "MM/dd/yyyy"; dtSearchDateTo.EditValue = (DateTime?)db.fn_ServerDateTime(); //lueSearchCustomer.Properties.AppearanceFocused.BackColor = Color.Yellow; //lueSearchCustomer.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; gvList.PopulateColumns(); }
public void Initialized() { Functions.QueryCmbAvailablePOList(db, ref lueSearchPO, "CVE", "", "", true); barEditCopies.EditValue = 1; dtSearchDateFrom.EditValue = Convert.ToDateTime(db.fn_ServerDateTime()).AddDays(-7); dtSearchDateFrom.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; dtSearchDateFrom.Properties.Mask.EditMask = "MM/dd/yyyy"; dtSearchDateTo.EditValue = (DateTime?)db.fn_ServerDateTime(); dtSearchDateFrom.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateFrom.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; dtSearchDateTo.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateTo.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchPO.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchPO.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; }
public void Initialized() { lueCustomer.EditValue = null; txtPONumber.Text = ""; deOrderDate.EditValue = DateTime.Now; lueStatus.EditValue = ""; txtRemark.Text = ""; txtPOHeaderID.Text = ""; deOrderDate.EditValue = Convert.ToDateTime(db.fn_ServerDateTime()).AddDays(-7); deOrderDate.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; deOrderDate.Properties.Mask.EditMask = "MM/dd/yyyy"; Functions.QueryCmbCustomerList(db, ref lueCustomer); Functions.QueryCmbOpenClosed(ref lueStatus); Functions.QueryCmbUserCodeData(db, ref lueSearchPOType, lueSearchPOType.Tag.ToString()); lueCustomer.Properties.AppearanceFocused.BackColor = Color.Yellow; lueCustomer.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchPOType.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchPOType.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; deOrderDate.Properties.AppearanceFocused.BackColor = Color.Yellow; deOrderDate.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueStatus.Properties.AppearanceFocused.BackColor = Color.Yellow; lueStatus.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; txtPONumber.Properties.AppearanceFocused.BackColor = Color.Yellow; txtPONumber.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; txtRemark.Properties.AppearanceFocused.BackColor = Color.Yellow; txtRemark.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; gcPODetail.DataSource = dtPODetails; //gcPODetail.DataSource = null; }
public void Initialized() { //gcTotal.DataSource = null; //GridView view = new GridView(gcTotal); ////view.OptionsView.ShowGroupPanel = false; ////view.OptionsView.ShowColumnHeaders = false; //gcTotal.MainView = view; Functions.QueryCmbCustomerList(db, ref lueSearchCustomer, true); string customerCode = lueSearchCustomer.Properties.GetKeyValueByDisplayText(lueSearchCustomer.Text).ToString(); Functions.QueryCmbUserCodeData(db, ref lueSearchPOType, lueSearchPOType.Tag.ToString(), "", true); string pOType = lueSearchPOType.Properties.GetKeyValueByDisplayText(lueSearchPOType.Text).ToString(); //dtSearchDateFrom.EditValue = Convert.ToDateTime(db.fn_ServerDateTime()).AddDays(-90); dtSearchDateFrom.EditValue = Convert.ToDateTime("01/01/2010"); dtSearchDateFrom.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; dtSearchDateFrom.Properties.Mask.EditMask = "MM/dd/yyyy"; //dtSearchDateTo.EditValue = (DateTime?)db.fn_ServerDateTime(); dtSearchDateTo.EditValue = Convert.ToDateTime(db.fn_ServerDateTime()); dtSearchDateTo.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime; dtSearchDateTo.Properties.Mask.EditMask = "MM/dd/yyyy"; dtSearchDateFrom.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateFrom.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; dtSearchDateTo.Properties.AppearanceFocused.BackColor = Color.Yellow; dtSearchDateTo.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchCustomer.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchCustomer.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; lueSearchPOType.Properties.AppearanceFocused.BackColor = Color.Yellow; lueSearchPOType.Properties.AppearanceReadOnly.BackColor = Color.LightGoldenrodYellow; barEditYieldRate.EditValue = 85; }
public Boolean SaveData() { try { if (gvPODetail.IsEditing) { gvPODetail.CloseEditor(); } if (gvPODetail.FocusedRowModified) { gvPODetail.UpdateCurrentRow(); } Cursor.Current = Cursors.WaitCursor; intPOHeaderID = Convert.ToInt16(txtPOHeaderID.Text); int intCustomerID; string strCustomerCode = lueCustomer.EditValue.ToString(); string strPOType = lueSearchPOType.EditValue.ToString(); string strPONumber = txtPONumber.Text.Trim(); if (string.IsNullOrEmpty(strPONumber)) { XtraMessageBox.Show("Please, input P/O Number first.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPONumber.Focus(); return(false); } DateTime dtOrderDate = Convert.ToDateTime(deOrderDate.EditValue.ToString()); //string strOrderDate = deOrderDate.EditValue.ToString(); //DateTime dtOrderDate; //if (DateTime.TryParseExact(strOrderDate, "M/d/yyyy", null, System.Globalization.DateTimeStyles.None, out dtOrderDate) == false) //{ // XtraMessageBox.Show("Order Date is not valid", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); // deOrderDate.Focus(); // return false; //} Boolean blnStatus = Convert.ToBoolean(lueStatus.Properties.GetKeyValueByDisplayText(lueStatus.Text).ToString()); string strRemark = txtRemark.Text; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); var qryPOHeader = (from poh in db.POHeaders from cst in db.Customers where cst.CustomerID == poh.CustomerID && cst.CustomerCode == strCustomerCode && poh.PONumber == strPONumber select poh).FirstOrDefault(); if (qryPOHeader == null) { // new add row var qryCount = (from poh in db.POHeaders from cst in db.Customers where cst.CustomerID == poh.CustomerID && cst.CustomerCode == strCustomerCode && poh.PONumber == strPONumber select poh).Count(); if (qryCount > 0) { MessageBox.Show("Already regist PO Number." + Environment.NewLine + "Please, check the PO Number!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPONumber.Focus(); return(false); } POHeader poheader = new POHeader(); intCustomerID = (from obj in db.Customers where obj.CustomerCode == strCustomerCode select obj.CustomerID).FirstOrDefault(); poheader.CustomerID = intCustomerID; poheader.PONumber = strPONumber; poheader.POType = strPOType; poheader.OrderDate = dtOrderDate; poheader.Status = blnStatus; if (blnStatus == true) { poheader.ClosedDate = dtServerDate; } poheader.CreateDate = dtServerDate; poheader.CreateCompName = Environment.MachineName; poheader.ModifiedDate = dtServerDate; poheader.ModifiedCompName = Environment.MachineName; db.POHeaders.InsertOnSubmit(poheader); } else { intCustomerID = (from obj in db.Customers where obj.CustomerCode == strCustomerCode select obj.CustomerID).FirstOrDefault(); qryPOHeader.CustomerID = intCustomerID; qryPOHeader.POType = strPOType; qryPOHeader.PONumber = strPONumber; qryPOHeader.OrderDate = dtOrderDate; qryPOHeader.Status = blnStatus; qryPOHeader.Remark = strRemark; qryPOHeader.ModifiedCompName = Environment.MachineName; qryPOHeader.ModifiedDate = dtServerDate; } db.SubmitChanges(); intPOHeaderID = (from obj in db.POHeaders where obj.CustomerID == intCustomerID && obj.PONumber == strPONumber select obj.POHeaderID).FirstOrDefault(); // PO Detail delete for (int i = 0; i < gvPODetail.DataRowCount; i++) { int intPODetailID = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "PODetailID").ToString()); int intPOLineNumber; try { intPOLineNumber = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "POLineNumber").ToString()); } catch { intPOLineNumber = 1; } string strItemNumber = gvPODetail.GetRowCellValue(i, "ItemNumber").ToString(); var qryItem = (from itm in db.ItemMasters from itd in db.ItemByCustomers where itd.ItemID == itm.ItemID && itd.CustomerID == intCustomerID && itd.ItemNumber == strItemNumber && itd.ItemType.Contains("R") select new { ItemID = itm.ItemID, ItemCode = itm.ItemCode } ).FirstOrDefault(); int intItemID = qryItem.ItemID; string strItemCode = qryItem.ItemCode; DateTime?dtDueDate; try { dtDueDate = Convert.ToDateTime(gvPODetail.GetRowCellValue(i, "DueDate").ToString()); } catch { dtDueDate = null; } int intReceivingQty = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "ReceiveQty").ToString()); //int intShipGoodQty = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "ShipGoodQty").ToString()); //int intShipFunctionFailQty = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "ShipFunctionFailQty").ToString()); //int intShipDIPQty = Convert.ToInt16(gvPODetail.GetRowCellValue(i, "ShipDIPQty").ToString()); string strStatus = gvPODetail.GetRowCellValue(i, "Status").ToString(); Boolean blnStatusDetail = Convert.ToBoolean(gvPODetail.GetRowCellValue(i, "Status").ToString()); var qryDetail = (from obj in db.PODetails where obj.PODetailID == intPODetailID select obj).FirstOrDefault(); if (qryDetail == null) { PODetail dtl = new PODetail(); dtl.POHeaderID = intPOHeaderID; dtl.POLineNumber = intPOLineNumber; dtl.PONumber = strPONumber; dtl.ItemID = intItemID; dtl.ItemCode = strItemCode; dtl.ItemNumber = strItemNumber; dtl.ReceiveQty = intReceivingQty; dtl.DueDate = dtDueDate; //dtl.ShipGoodQty = intShipGoodQty; //dtl.ShipDIPQty = intShipDIPQty; //dtl.ShipFunctionFailQty = intShipFunctionFailQty; //dtl.ShipDIPQty = intShipDIPQty; dtl.Status = blnStatusDetail; dtl.CreatedDate = dtServerDate; dtl.CreatedHostName = Environment.MachineName; db.PODetails.InsertOnSubmit(dtl); } else { if (!(qryDetail.POHeaderID == intPOHeaderID && qryDetail.POLineNumber == intPOLineNumber && qryDetail.PONumber == strPONumber && qryDetail.ItemID == intItemID && qryDetail.ItemCode == strItemCode && qryDetail.ItemNumber == strItemNumber && qryDetail.ReceiveQty == intReceivingQty //&& qryDetail.ShipGoodQty == intShipGoodQty //&& qryDetail.ShipFunctionFailQty == intShipFunctionFailQty //&& qryDetail.ShipDIPQty == intShipDIPQty && qryDetail.DueDate == dtDueDate && qryDetail.Status == blnStatusDetail)) { qryDetail.POHeaderID = intPOHeaderID; qryDetail.PONumber = strPONumber; qryDetail.POLineNumber = intPOLineNumber; qryDetail.ItemID = intItemID; qryDetail.ItemCode = strItemCode; qryDetail.ItemNumber = strItemNumber; qryDetail.ReceiveQty = intReceivingQty; qryDetail.DueDate = dtDueDate; //qryDetail.ShipGoodQty = intShipGoodQty; //qryDetail.ShipDIPQty = intShipDIPQty; //qryDetail.ShipFunctionFailQty = intShipFunctionFailQty; //qryDetail.ShipDIPQty = intShipDIPQty; qryDetail.Status = blnStatus; qryDetail.CreatedDate = dtServerDate; qryDetail.CreatedHostName = Environment.MachineName; } } db.SubmitChanges(); if (strEntryStatus == "A") { txtPOHeaderID.Text = intPOHeaderID.ToString(); strEntryStatus = "E"; } } } scope.Complete(); } MessageBox.Show("Completed Saved!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Exception Error!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SearchData(); Cursor.Current = Cursors.Default; } return(false); }
private void btnCancelPalletize_Click(object sender, EventArgs e) { try { string strPalletNo = txtPalletID.Text.Trim(); DialogResult result = XtraMessageBox.Show(string.Format("Would you like to Cancel to Pallet [{0}] ? ", strPalletNo), "Question!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) { return; } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); if (string.IsNullOrEmpty(strPalletNo)) { return; } var qryShips = from shp in db.POShipments from plt in db.POPalletInfos where shp.POPalletID == plt.POPalletID && plt.PalletNo == Convert.ToDecimal(strPalletNo) select shp; foreach (POShipment shp in qryShips) { shp.POPalletID = null; shp.ModifiedCompName = Environment.MachineName; shp.ModifiedDate = dtServerDate; } var qryPlt = (from plt in db.POPalletInfos where plt.PalletNo == Convert.ToDecimal(strPalletNo) select plt).FirstOrDefault(); db.POPalletInfos.DeleteOnSubmit(qryPlt); db.SubmitChanges(); } scope.Complete(); } XtraMessageBox.Show("Cancelled palletizied!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); btnResetPallet.PerformClick(); } catch (Exception ex) { string errMsg; if (ex.InnerException == null) { errMsg = ex.Message.ToString(); } else { errMsg = ex.InnerException.ToString(); } XtraMessageBox.Show("failed to retrieveing for Pallet" + Environment.NewLine + errMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { Cursor.Current = Cursors.Default; } }
private void btnCreatePallet_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; string strPalletNo; int poPalletID; try { if (gvPalletize.RowCount == 0) { return; } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); strPalletNo = dtServerDate.ToString("yyMMddHHmmss"); //palletNo = Convert.ToInt32(dtServerDate.ToString("yyMMddHHmmss")); var qryPalletCnt = (from obj in db.POPalletInfos where obj.PalletNo == Convert.ToDecimal(strPalletNo) select obj).Count(); if (qryPalletCnt > 0) { XtraMessageBox.Show(string.Format("Already using the pallet no [{0}]", strPalletNo.ToString()), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } POPalletInfo pOPalletInfo = new POPalletInfo(); pOPalletInfo.PalletNo = Convert.ToDecimal(strPalletNo); pOPalletInfo.PalletDate = dtServerDate; pOPalletInfo.CreatedDate = dtServerDate; pOPalletInfo.CreatedHostName = Environment.MachineName; db.POPalletInfos.InsertOnSubmit(pOPalletInfo); db.SubmitChanges(); poPalletID = (from obj in db.POPalletInfos where obj.PalletNo == Convert.ToDecimal(strPalletNo) select obj.POPalletID).FirstOrDefault(); txtPalletID.Text = strPalletNo; for (int i = 0; i < gvPalletize.RowCount; i++) { Int16 shipmentID = Convert.ToInt16(gvPalletize.GetRowCellValue(i, "ShipmentID").ToString()); var qryShipment = (from obj in db.POShipments where obj.ShipmentID == shipmentID select obj).FirstOrDefault(); qryShipment.POPalletID = poPalletID; qryShipment.ModifiedCompName = Environment.MachineName; qryShipment.ModifiedDate = dtServerDate; } txtPalletID_Info.EditValue = strPalletNo; db.SubmitChanges(); } scope.Complete(); } if (chkPackingList.Checked == true) { // print packing list try { if (!string.IsNullOrEmpty(strPalletNo)) { decimal palletNo = Convert.ToDecimal(strPalletNo); string customerCode = Convert.ToString(gvPalletize.GetRowCellValue(1, "CustomerCode")); string location = ""; if (customerCode == "CVE") { if (chkAllen.Checked) { location = "ALLEN"; } else if (chkPlano.Checked) { location = "PLANO"; } else { XtraMessageBox.Show("Please, check to Ship Location.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { location = ""; } prtPackingList rpt = new prtPackingList(); rpt.Parameters["palletNo"].Value = palletNo; rpt.Parameters["location"].Value = location; rpt.PrintingSystem.StartPrint += new DevExpress.XtraPrinting.PrintDocumentEventHandler(PrintingSystem_StartPrint); rpt.Print(); } } catch (Exception ex) { XtraMessageBox.Show("Could not print packing list." + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } XtraMessageBox.Show("Completed Palletizing.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); btnResetPallet.PerformClick(); } catch (Exception ex) { string errMsg; if (ex.InnerException == null) { errMsg = ex.Message.ToString(); } else { errMsg = ex.InnerException.ToString(); } XtraMessageBox.Show("Failed to packing!" + Environment.NewLine + errMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } }
public Boolean SaveData() { try { Cursor.Current = Cursors.WaitCursor; intCustomerID = Convert.ToInt16(txtCustomerID.Text); string strCustomerCode = (txtCustomerCode.Text).ToUpper().Trim(); string strCustomerName = (txtCustomerName.Text).Trim(); string strContactName = (txtContactName.Text).Trim(); string strContactTitle = (txtContactTitle.Text).Trim(); string strAddress1 = (txtAddress1.Text).Trim(); string strAddress2 = (txtAddress2.Text).Trim(); string strCity = (txtCity.Text).Trim(); string strState = lueState.EditValue.ToString(); string strPostalCode = (txtPostalCode.Text).Trim(); string strPhone = (txtPhone.Text).Trim(); string strFax = (txtFax.Text).Trim(); string strPaymentTerm = (luePaymentTerm.EditValue).ToString(); string strUseYN = (lueUseYN.EditValue.ToString()); bool blnUseYN; if (string.IsNullOrEmpty(strCustomerCode)) { XtraMessageBox.Show("Please, input Customer Code first.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCustomerCode.Focus(); return(false); } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); var qryCustomer = (from cst in db.Customers where cst.CustomerCode == strCustomerCode select cst).FirstOrDefault(); if (qryCustomer == null) { // new add row var qryCount = (from cst in db.Customers where cst.CustomerCode == strCustomerCode select cst).Count(); if (qryCount > 0) { MessageBox.Show("Already regist Customer Code" + Environment.NewLine + "Please, check Customer List!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCustomerCode.Focus(); return(false); } Customer customer = new Customer(); customer.CustomerCode = strCustomerCode; customer.CustomerName = strCustomerName; customer.ContactName = strContactName; customer.ContactTitle = strContactTitle; customer.Address1 = strAddress1; customer.Address2 = strAddress2; customer.City = strCity; customer.State = strState; customer.PostalCode = strPostalCode; customer.Phone = strPhone; customer.Fax = strFax; customer.PaymentTerm = strPaymentTerm; if (strUseYN == "Y") { blnUseYN = true; } else { blnUseYN = false; } customer.UseYN = blnUseYN; customer.CreateDate = dtServerDate; customer.CreateCompName = Environment.MachineName; } else { intCustomerID = (from obj in db.Customers where obj.CustomerCode == strCustomerCode select obj.CustomerID).FirstOrDefault(); qryCustomer.CustomerCode = strCustomerCode; qryCustomer.CustomerName = strCustomerName; qryCustomer.ContactName = strContactName; qryCustomer.ContactTitle = strContactTitle; qryCustomer.Address1 = strAddress1; qryCustomer.Address2 = strAddress2; qryCustomer.City = strCity; qryCustomer.State = strState; qryCustomer.PostalCode = strPostalCode; qryCustomer.Phone = strPhone; qryCustomer.Fax = strFax; qryCustomer.PaymentTerm = strPaymentTerm; } db.SubmitChanges(); if (strEntryStatus == "A") { txtCustomerID.Text = intCustomerID.ToString(); strEntryStatus = "E"; } } scope.Complete(); } MessageBox.Show("Completed Saved!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Exception Error!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SearchData(); Cursor.Current = Cursors.Default; } return(false); }
public Boolean SaveData() { Int16 intCustomerID, intItemID, intItemNumberID; try { Cursor.Current = Cursors.WaitCursor; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); string strCustomerCode = lueCustomer.EditValue.ToString(); if (string.IsNullOrEmpty(strCustomerCode)) { XtraMessageBox.Show("Please, check the Customer Data!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); lueCustomer.Focus(); return(false); } string strItemInternal = lueItemInternal.EditValue.ToString(); if (string.IsNullOrEmpty(strItemInternal)) { XtraMessageBox.Show("Please, check the Internal Item Code Data!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); lueItemInternal.Focus(); return(false); } string strItemExternal = lueItemExternal.EditValue.ToString(); if (string.IsNullOrEmpty(strItemExternal)) { XtraMessageBox.Show("Please, check the External Item Code Data!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); lueItemExternal.Focus(); return(false); } string strItemType = lueItemType.EditValue.ToString(); if (string.IsNullOrEmpty(strItemType)) { XtraMessageBox.Show("Please, check the Item Type!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); lueItemType.Focus(); return(false); } string strUseYN = lueUseYN.EditValue.ToString(); if (string.IsNullOrEmpty(strUseYN)) { XtraMessageBox.Show("Please, check the External Item Code Data!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); lueUseYN.Focus(); return(false); } Int16 intItemDetailID = Convert.ToInt16(txtItemDetailID.Text.Trim()); if (AddEditStatus == "A") { ItemByCustomer ibc = new ItemByCustomer(); var qryCustomer = (from a in db.Customers where a.CustomerCode == strCustomerCode select a).FirstOrDefault(); ibc.CustomerID = qryCustomer.CustomerID; ibc.ItemID = Convert.ToInt16(strItemInternal); ibc.ItemCode = (from a in db.ItemMasters where a.ItemID == Convert.ToInt16(strItemInternal) select a.ItemCode).FirstOrDefault(); ibc.ItemNumberID = Convert.ToInt16(strItemExternal); ibc.ItemNumber = (from a in db.ItemMasters where a.ItemID == Convert.ToInt16(strItemExternal) select a.ItemCode).FirstOrDefault(); ibc.ItemType = strItemType; Boolean blnUseYN; if (strUseYN == "Y") { blnUseYN = true; } else { blnUseYN = false; } ibc.UseYN = blnUseYN; ibc.CreateCompName = Environment.MachineName; ibc.CreateDate = dtServerDate; intCustomerID = Convert.ToInt16(qryCustomer.CustomerID); intItemID = Convert.ToInt16(strItemInternal); intItemNumberID = Convert.ToInt16(strItemExternal); db.ItemByCustomers.InsertOnSubmit(ibc); db.SubmitChanges(); var qry = (from obj in db.ItemByCustomers where obj.CustomerID == intCustomerID && obj.ItemID == intItemID && obj.ItemNumberID == intItemNumberID select obj.ItemDetailID).FirstOrDefault(); itemDetailID = Convert.ToInt16(qry); } else { var qryItemByCustomer = (from obj in db.ItemByCustomers where obj.ItemDetailID == intItemDetailID select obj).FirstOrDefault(); if (qryItemByCustomer != null) { var qryCustomer = (from a in db.Customers where a.CustomerCode == strCustomerCode select a).FirstOrDefault(); qryItemByCustomer.CustomerID = qryCustomer.CustomerID; qryItemByCustomer.ItemID = Convert.ToInt16(strItemInternal); qryItemByCustomer.ItemCode = (from a in db.ItemMasters where a.ItemID == Convert.ToInt16(strItemInternal) select a.ItemCode).FirstOrDefault(); qryItemByCustomer.ItemNumberID = Convert.ToInt16(strItemExternal); qryItemByCustomer.ItemNumber = (from a in db.ItemMasters where a.ItemID == Convert.ToInt16(strItemInternal) select a.ItemCode).FirstOrDefault(); qryItemByCustomer.ItemType = strItemType; Boolean blnUseYN; if (strUseYN == "Y") { blnUseYN = true; } else { blnUseYN = false; } qryItemByCustomer.UseYN = blnUseYN; qryItemByCustomer.ModifiedCompName = Environment.MachineName; qryItemByCustomer.ModifiedDate = dtServerDate; itemDetailID = intItemDetailID; } db.SubmitChanges(); } } scope.Complete(); } MessageBox.Show("Completed Saved!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); //int rowHandle = GetRowHandleByColumnValue(gvList, "ItemDetailID", itemDetailID); //if (rowHandle != GridControl.InvalidRowHandle) //{ // gvList.FocusedColumn = gvList.Columns.ColumnByFieldName("ItemDetailID"); // gvList.FocusedRowHandle = rowHandle; // //gvList.ShowEditor(); //} } catch (Exception ex) { MessageBox.Show("Exception Error!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } return(true); }
private Boolean DeleteShipBox() { try { Cursor.Current = Cursors.WaitCursor; string strShipBoxNo = gvList.GetRowCellValue(gvList.FocusedRowHandle, "ShipBoxNo").ToString(); if (string.IsNullOrEmpty(strShipBoxNo)) { XtraMessageBox.Show("Please, Could not get Ship Box#.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } DialogResult result = XtraMessageBox.Show("Do you want to delete Box Data?", "Question!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) { return(false); } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { using (eSolutionDataContext db = new eSolutionDataContext()) { DateTime dtServerDate = Convert.ToDateTime(db.fn_ServerDateTime().ToString()); string strShippingStatus = gvList.GetRowCellValue(gvList.FocusedRowHandle, "ShippingStatus").ToString();; string strShippingType = strShippingStatus.Substring(0, 1); Int16 intShippedQty = Convert.ToInt16(gvList.GetRowCellValue(gvList.FocusedRowHandle, "ShippedQty").ToString()); var qryShipment = (from obj in db.POShipments where obj.ShipBoxNo == strShipBoxNo select obj).FirstOrDefault(); if (qryShipment == null) { MessageBox.Show("Could not find Ship Box Data." + Environment.NewLine + "Please, check the history", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (qryShipment.POPalletID > 0) { MessageBox.Show("Already Palletized." + Environment.NewLine + "Please, un-palletized first!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } var qryPODetail = (from pod in db.PODetails where pod.PODetailID == qryShipment.PODetailID select pod).FirstOrDefault(); if (qryPODetail == null) { return(false); } //switch (strShippingType) //{ // case "G": // qryPODetail.ShipGoodQty = qryPODetail.ShipGoodQty - c; // break; // case "F": // qryPODetail.ShipFunctionFailQty = qryPODetail.ShipFunctionFailQty - intShippedQty; // break; // case "D": // qryPODetail.ShipDIPQty = qryPODetail.ShipDIPQty - intShippedQty; // break; //} //CodeName CodeSeq CodeDescription //GREF 1 Refurbished //GFRO 2 Front Only //DDEF 3 Defective //FRFF 4 Receiving Function Fail //GSMP 5 Sample //GNTF 6 NTF //ROOW 7 Out Of Warrnty //RCTA 8 Customer Abuse switch (strShippingStatus) { case "GREF": qryPODetail.ShipRefurbishedQty = qryPODetail.ShipRefurbishedQty - intShippedQty; break; case "GFCL": qryPODetail.ShipRefurbishedFPCBQty = qryPODetail.ShipRefurbishedFPCBQty - intShippedQty; break; case "GFRO": qryPODetail.ShipFrontOnly = qryPODetail.ShipFrontOnly - intShippedQty; break; case "DDEF": case "DIP": qryPODetail.ShipDIPQty = qryPODetail.ShipDIPQty - intShippedQty; break; case "FRFF": qryPODetail.ShipFunctionFailQty = qryPODetail.ShipFunctionFailQty - intShippedQty; break; case "GSMP": qryPODetail.ShipSampleQty = qryPODetail.ShipSampleQty - intShippedQty; break; case "GNTF": qryPODetail.ShipNTFQty = qryPODetail.ShipNTFQty - intShippedQty; break; case "ROOW": qryPODetail.ShipOutOfWarranty = qryPODetail.ShipOutOfWarranty - intShippedQty; break; case "RCTA": qryPODetail.ShipCustomerAbuse = qryPODetail.ShipCustomerAbuse - intShippedQty; break; case "NMP": qryPODetail.ShipNMPQty = qryPODetail.ShipNMPQty - intShippedQty; break; } if (qryPODetail.Status == true) { qryPODetail.Status = false; } qryPODetail.ModifiedDate = dtServerDate; qryPODetail.ModifiedHostName = Environment.MachineName; var qryPOHeader = (from poh in db.POHeaders where poh.POHeaderID == qryPODetail.POHeaderID select poh).FirstOrDefault(); if (qryPOHeader == null) { return(false); } qryPOHeader.Status = false; qryPOHeader.ModifiedDate = dtServerDate; qryPOHeader.ModifiedCompName = Environment.MachineName; db.POShipments.DeleteOnSubmit(qryShipment); try { db.SubmitChanges(); } catch (Exception ex) { MessageBox.Show("Could not delete to Ship Box#!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } scope.Complete(); } MessageBox.Show("Delete Completed!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } catch (Exception ex) { MessageBox.Show("Could not delete to Ship Box#!" + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }