Beispiel #1
0
        public static void QueryCheckCmbPOTypeList(eSolutionDataContext db, ref CheckedComboBoxEdit cmbName, Boolean argAll = false)
        {
            DataTable dt = DatabaseHelper.GetUserCodeData(db, "POTYPE", "COMMON", false);

            cmbName.Properties.Items.Clear();
            cmbName.Properties.DataSource = null;

            if (dt.Rows.Count > 0)
            {
                cmbName.Properties.DataSource = dt;
                cmbName.Properties.ValueMember = "ValueMember";
                cmbName.Properties.DisplayMember = "DisplayMember";
                cmbName.Properties.Items.Add("Value", CheckState.Unchecked, true);
                cmbName.CheckAll();
                cmbName.SetEditValue(0);
                cmbName.CheckAll();
            }
            else
            {
                cmbName.SetEditValue(null);
            }
            cmbName.Properties.PopupControl = null;
            cmbName.Properties.SeparatorChar = ';';
            cmbName.Properties.PopupResizeMode = DevExpress.XtraEditors.Controls.ResizeMode.LiveResize;

        }
Beispiel #2
0
        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 static DataTable GetStateCode(eSolutionDataContext db, Boolean argAll = false)
        {
            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                //var sqlQuery = eMESdb.stp_CustomerList();
                //var sqlQuery = db.stp_UserCodeData_Select(argTableName, argCodeGroup).ToList();
                var sqlQuery = from obj in db.States
                               select new
                {
                    DisplayName = obj.Code
                    ,
                    CodeName = obj.Code
                };
                //var sqlQuery = from obj in db.UserCodeDatas
                //               where obj.TableName == argTableName
                //                && obj.CodeGroup.Contains(argCodeGroup)
                //               orderby obj.CodeSeq
                //               select new
                //               {
                //                   DisplayName = obj.CodeDescription
                //                   , CodeName = obj.CodeName
                //               };
                if (argAll == true)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = "ALL";
                    newRow[HelperClass.CodeName]    = "";
                    dt.Rows.Add(newRow);
                }
                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = row.DisplayName;
                    newRow[HelperClass.CodeName]    = row.CodeName;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            { }

            return(dt);
        }
        public static DataTable GetCustomerList(eSolutionDataContext db, Boolean argAll = false)
        {
            //EMSdb = new eSolutionDataContext();

            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                var sqlQuery = db.stp_CustomerList().ToList();
                //var sqlQuery = from obj in db.Customers
                //               group obj by new
                //               {
                //                   obj.CustomerCode
                //                   ,
                //                   obj.CustomerName
                //               }
                //                   into grouping
                //                   select new { grouping.Key, grouping };
                if (argAll == true)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = "ALL";
                    newRow[HelperClass.CodeName]    = "";
                    dt.Rows.Add(newRow);
                }
                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    //newRow[HelperClass.DisplayName] = row.Key.CustomerName;
                    //newRow[HelperClass.CodeName] = row.Key.CustomerCode;
                    newRow[HelperClass.DisplayName] = row.DisplayName;
                    newRow[HelperClass.CodeName]    = row.CodeName;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            {
                dt = null;
            }
            finally
            {
            }
            return(dt);
        }
        public static DataTable GetItemCode(eSolutionDataContext db, string itemType = "I")
        {
            //EMSdb = new eSolutionDataContext();

            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                //var sqlQuery = eMESdb.stp_CustomerList();
                var sqlQuery = from obj in db.ItemMasters
                               where obj.ItemType == itemType
                               group obj by new
                {
                    obj.ItemID
                    ,
                    obj.ItemCode
                }
                into grouping
                    select new { grouping.Key, grouping };

                newRow = dt.NewRow();
                newRow[HelperClass.DisplayName] = "";
                newRow[HelperClass.CodeName]    = "";
                dt.Rows.Add(newRow);

                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = row.Key.ItemCode;
                    newRow[HelperClass.CodeName]    = row.Key.ItemID;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            {
                dt = null;
            }
            finally
            {
            }
            return(dt);
        }
        public static DataTable GetCustomerItemList(eSolutionDataContext db, string CustomerCode, string RSType = "")
        {
            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            //select *
            //  from ItemByCustomer a
            //     , Customer b
            // where b.CustomerID = a.CustomerID
            //   and b.CustomerCode = 'CVE'
            //   and a.ItemType like '%S%'

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                var sqlQuery = from itm in db.ItemByCustomers
                               from cst in db.Customers
                               where itm.CustomerID == cst.CustomerID &&
                               cst.CustomerCode == CustomerCode &&
                               itm.ItemType.Contains(RSType)
                               orderby itm.ItemNumber
                               select new
                {
                    ItemNumber = itm.ItemNumber,
                }
                ;
                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = row.ItemNumber;
                    newRow[HelperClass.CodeName]    = row.ItemNumber;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            {
                dt = null;
            }
            finally
            {
            }
            return(dt);
        }
Beispiel #7
0
        public static void QueryCmbState(eSolutionDataContext db, ref LookUpEdit cmbName, Boolean allFlag = false)
        {
            DataTable dt = DatabaseHelper.GetStateCode(db, allFlag);
            cmbName.Properties.DataSource = null;
            cmbName.Properties.ValueMember = string.Empty;
            cmbName.Properties.DisplayMember = string.Empty;
            cmbName.Properties.Columns.Clear();

            cmbName.Properties.DataSource = dt;
            cmbName.Properties.ValueMember = "ValueMember";
            cmbName.Properties.DisplayMember = "DisplayMember";
            cmbName.Properties.ForceInitialize();
            cmbName.Properties.PopulateColumns();
            cmbName.Properties.Columns["ValueMember"].Visible = false;
            cmbName.EditValue = cmbName.Properties.GetDataSourceValue(cmbName.Properties.ValueMember, 0);
        }
Beispiel #8
0
        public static void QueryCmbCustomerItemList(eSolutionDataContext db, ref LookUpEdit cmbName, string CustomerCode, string RSType = "S")
        {
            DataTable dt = DatabaseHelper.GetCustomerItemList(db, CustomerCode, RSType);

            cmbName.Properties.DataSource = null;
            cmbName.Properties.ValueMember = string.Empty;
            cmbName.Properties.DisplayMember = string.Empty;
            cmbName.Properties.Columns.Clear();

            cmbName.Properties.DataSource = dt;
            cmbName.Properties.ValueMember = "ValueMember";
            cmbName.Properties.DisplayMember = "DisplayMember";
            cmbName.Properties.ForceInitialize();
            cmbName.Properties.PopulateColumns();
            cmbName.Properties.Columns["ValueMember"].Visible = false;
            cmbName.EditValue = cmbName.Properties.GetDataSourceValue(cmbName.Properties.ValueMember, 0);
        }
Beispiel #9
0
        public static void QueryCmbItemType(eSolutionDataContext db, ref LookUpEdit cmbName, Boolean argALL = false)
        {
            DataTable dt = DatabaseHelper.GetUserCodeData(db, cmbName.Tag.ToString(), "", argALL);

            cmbName.Properties.DataSource = null;
            cmbName.Properties.ValueMember = string.Empty;
            cmbName.Properties.DisplayMember = string.Empty;
            cmbName.Properties.Columns.Clear();

            cmbName.Properties.DataSource = dt;
            cmbName.Properties.ValueMember = "ValueMember";
            cmbName.Properties.DisplayMember = "DisplayMember";
            cmbName.Properties.ForceInitialize();
            cmbName.Properties.PopulateColumns();
            cmbName.Properties.Columns["ValueMember"].Visible = false;
            cmbName.EditValue = cmbName.Properties.GetDataSourceValue(cmbName.Properties.ValueMember, 0);
        }
Beispiel #10
0
        public static DataTable GetCodeAvailablePOList(eSolutionDataContext db)
        {
            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                //var sqlQuery = eMESdb.stp_CustomerList();
                var sqlQuery = from obj in db.POHeaders
                               where obj.Status == false
                               orderby obj.PONumber
                               select new
                {
                    POID = obj.POHeaderID,
                    PONO = obj.PONumber
                };
                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = row.PONO;
                    newRow[HelperClass.CodeName]    = row.PONO;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            {
                dt = null;
            }
            finally
            {
            }
            return(dt);
        }
Beispiel #11
0
        public static void QueryCmbShippingStatus(eSolutionDataContext db, ref LookUpEdit cmbName, string codeGroup = "", Boolean argAll = false)
        {
            DataTable dt = DatabaseHelper.GetUserCodeData(db, cmbName.Tag.ToString(), codeGroup);

            cmbName.Properties.DataSource = null;
            try
            {
                cmbName.Properties.ValueMember = string.Empty;
                cmbName.Properties.DisplayMember = string.Empty;
            }
            catch
            {
            }
            cmbName.Properties.Columns.Clear();

            cmbName.Properties.DataSource = dt;
            cmbName.Properties.ValueMember = "ValueMember";
            cmbName.Properties.DisplayMember = "DisplayMember";
            cmbName.Properties.ForceInitialize();
            cmbName.Properties.PopulateColumns();
            cmbName.Properties.Columns["ValueMember"].Visible = false;
            cmbName.EditValue = cmbName.Properties.GetDataSourceValue(cmbName.Properties.ValueMember, 0);
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        private void txtPalletID_KeyDown(object sender, KeyEventArgs e)
        {
            string strPalletID = txtPalletID.Text.Trim();

            if (string.IsNullOrEmpty(strPalletID))
            {
                txtPalletID.Focus();
                return;
            }

            if (e.Handled)
            {
                txtPalletID.Focus();
                return;
            }

            if (e.KeyData == Keys.Enter)
            {
                try
                {
                    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                        IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
                    }))
                    {
                        using (eSolutionDataContext db = new eSolutionDataContext())
                        {
                            string strPalletNo = txtPalletID.Text.Trim();
                            if (string.IsNullOrEmpty(strPalletNo))
                            {
                                return;
                            }

                            var qry = db.stp_POPalletInfo_Select("%", "%", strPalletNo);

                            if (qry != null)
                            {
                                dataTablePackingList   = Functions.LINQToDataTable(qry);
                                gcPalletize.DataSource = dataTablePackingList;

                                // Button Setting
                                btnCreatePallet.Enabled    = false;
                                btnUpdatePallet.Enabled    = true;
                                btnCancelPalletize.Enabled = true;

                                btnPrint.Enabled = true;
                            }
                            else
                            {
                                gcPalletize.DataSource = null;
                                XtraMessageBox.Show(string.Format("Could not found the Pallet No[{0}]!", strPalletNo), "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                // button setting
                                btnCreatePallet.Enabled    = true;
                                btnUpdatePallet.Enabled    = false;
                                btnCancelPalletize.Enabled = false;

                                btnPrint.Enabled = false;

                                txtPalletID.Focus();
                                return;
                            }
                        }
                        scope.Complete();
                    }
                }
                catch (Exception ex)
                {
                    string errMsg;
                    if (ex.InnerException == null)
                    {
                        errMsg = ex.Message.ToString();
                    }
                    else
                    {
                        errMsg = ex.InnerException.ToString();
                    }
                    XtraMessageBox.Show(string.Format("Could not found the Pallet No[{0}]!", strPalletID) + Environment.NewLine + errMsg, "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #14
0
        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;
            }
        }
Beispiel #15
0
        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);
        }
Beispiel #17
0
        public Boolean SaveData()
        {
            if (Validate() == false)
            {
                return(false);
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
                }))
                {
                    using (eSolutionDataContext db = new eSolutionDataContext())
                    {
                        string strItemID   = lueItemID.EditValue.ToString();
                        Int16  intItemID   = Convert.ToInt16(strItemID);
                        string strItemCode = lueItemCode.EditValue.ToString();
                        strItemCode.Replace(" ", "");
                        strItemCode = strItemCode.ToUpper();
                        string  strItemDescription = lueItemDescription.EditValue.ToString();
                        string  strItemType        = lueItemType.EditValue.ToString();
                        string  strUseYN           = lueUseYN.EditValue.ToString();
                        Boolean blnUseYN;
                        if (strUseYN == "Y")
                        {
                            blnUseYN = true;
                        }
                        else
                        {
                            blnUseYN = false;
                        }

                        if (strModifiedFlag == "A")
                        {
                            // new add row
                            var qryCount = (from obj in db.ItemMasters
                                            where obj.ItemCode.Replace(" ", "").ToUpper() == strItemCode &&
                                            obj.ItemType == strItemType
                                            select obj).Count();
                            if (qryCount > 0)
                            {
                                MessageBox.Show("Already regist Item Code in Database." + Environment.NewLine + "Please, check the Item List!",
                                                "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return(false);
                            }
                            ItemMaster itemMaster = new ItemMaster();
                            itemMaster.ItemCode        = strItemCode;
                            itemMaster.ItemDescription = strItemDescription;
                            itemMaster.UseYN           = blnUseYN;
                            itemMaster.ItemType        = strItemType;

                            db.ItemMasters.InsertOnSubmit(itemMaster);
                        }
                        else
                        {
                            // modified data
                            var qry = (from obj in db.ItemMasters
                                       where obj.ItemID == intItemID
                                       select obj).FirstOrDefault();
                            if (qry == null)
                            {
                                MessageBox.Show("Not exists Model Code." + Environment.NewLine + "Please, check the Item List!",
                                                "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return(false);
                            }
                            qry.ItemCode        = strItemCode;
                            qry.ItemDescription = strItemDescription;
                            qry.ItemType        = strItemType;
                            qry.UseYN           = blnUseYN;
                        }
                        db.SubmitChanges();
                    }
                    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
            {
                Cursor.Current = Cursors.Default;
            }
            return(true);
        }
Beispiel #18
0
        public static DataTable GetCodeAvailablePOList(eSolutionDataContext db, string customerCode, string pOType, string pOStatus, Boolean allFlag)
        {
            //EMSdb = new eSolutionDataContext();

            DataTable  dt       = new DataTable();
            DataColumn colValue = new DataColumn();
            DataColumn colText  = new DataColumn();
            DataRow    newRow;

            try
            {
                colText.ColumnName  = HelperClass.DisplayName;
                colValue.ColumnName = HelperClass.CodeName;
                colText.DataType    = typeof(System.String);
                colValue.DataType   = typeof(System.String);

                dt.Columns.Add(colText);
                dt.Columns.Add(colValue);

                if (string.IsNullOrEmpty(customerCode))
                {
                    customerCode = "%";
                }
                if (string.IsNullOrEmpty(pOType))
                {
                    pOType = "%";
                }
                if (string.IsNullOrEmpty(pOStatus))
                {
                    pOStatus = "%";
                }

                var sqlQuery = db.stp_GetPOListByCustomer(customerCode, pOType, pOStatus).ToList();
                //var sqlQuery = from obj in db.POHeaders
                //               from cst in db.Customers
                //               where obj.CustomerID == cst.CustomerID
                //               && obj.POType == pOType
                //               && (obj.Status.ToString()).ToUpper().Contains(pOStatus)
                //               && cst.CustomerCode == customerCode
                //               orderby obj.PONumber
                //               select new
                //               {
                //                   POID = obj.POHeaderID,
                //                   PONO = obj.PONumber
                //               };
                if (allFlag == true)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = "ALL";
                    newRow[HelperClass.CodeName]    = "";
                    dt.Rows.Add(newRow);
                }
                foreach (var row in sqlQuery)
                {
                    newRow = dt.NewRow();
                    newRow[HelperClass.DisplayName] = row.PONumber;
                    newRow[HelperClass.CodeName]    = row.PONumber;
                    dt.Rows.Add(newRow);
                }
            }
            catch
            {
                dt = null;
            }
            finally
            {
            }
            return(dt);
        }
        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);
            }
        }
Beispiel #20
0
        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);
        }
Beispiel #21
0
        private void btnDeleteLine_Click(object sender, EventArgs e)
        {
            int intPODetailID;
            int intRow = gvPODetail.FocusedRowHandle;
            int poLineNumber;

            if (intRow < 0)
            {
                return;
            }

            intPODetailID = Convert.ToInt16(gvPODetail.GetRowCellValue(intRow, "PODetailID").ToString());
            if (intPODetailID == 0)
            {
                gvPODetail.DeleteRow(intRow);
                return;
            }

            poLineNumber = Convert.ToInt16(gvPODetail.GetRowCellValue(intRow, "POLineNumber").ToString());


            DialogResult dialogResult = XtraMessageBox.Show(string.Format("Do you want to delete Line Number {0}", poLineNumber.ToString()), "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (dialogResult == DialogResult.No)
            {
                return;
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;


                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
                }))
                {
                    using (eSolutionDataContext db = new eSolutionDataContext())
                    {
                        var qryDelete = from obj in db.PODetails
                                        where obj.PODetailID == intPODetailID
                                        select obj;
                        foreach (var dtl in qryDelete)
                        {
                            db.PODetails.DeleteOnSubmit(dtl);
                        }
                        try
                        { db.SubmitChanges(); }
                        catch (Exception ex)
                        {
                            string errMsg;
                            if (ex.InnerException == null)
                            {
                                errMsg = ex.Message.ToString();
                            }
                            else
                            {
                                errMsg = ex.InnerException.ToString();
                            }
                            XtraMessageBox.Show("Delete Failed!" + Environment.NewLine + errMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    scope.Complete();
                }
                SearchData();
            }
            catch (Exception ex)
            {
                string errMsg;
                if (ex.InnerException == null)
                {
                    errMsg = ex.Message.ToString();
                }
                else
                {
                    errMsg = ex.InnerException.ToString();
                }
                XtraMessageBox.Show("Delete Failed!" + Environment.NewLine + errMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #22
0
 public static DateTime GetSystemDateTime(ref eSolutionDataContext db)
 {
     return Convert.ToDateTime(db.stp_GetServerDatetime().SingleOrDefault().Now);
 }