Ejemplo n.º 1
0
        private void UpdateStock()
        {
            try
            {
                t_return_detail trans = new t_return_detail();
                trans.returnNo = txt_no.Text.Trim();
                List <t_return_detail> Transins = new List <t_return_detail>();
                Transins = new T_return_detailDL().SelectT_return_detailMulti(trans);

                foreach (t_return_detail det in Transins)
                {
                    T_Stock objt_Stock = new T_Stock();
                    objt_Stock.StockCode = det.stockCode;
                    objt_Stock.Compcode  = commonFunctions.GlobalCompany;
                    objt_Stock.Locacode  = commonFunctions.GlobalLocation;
                    objt_Stock           = new T_StockDL().Selectt_Stock_new(objt_Stock);

                    decimal currentst = decimal.Zero;
                    currentst        = commonFunctions.ToDecimal(objt_Stock.Stock.ToString()) - commonFunctions.ToDecimal(det.quantity.ToString());
                    objt_Stock.Stock = currentst;

                    new T_StockDL().SaveT_StockSP(objt_Stock, 3, 1);
                }
            }
            catch (Exception ex)
            {
                commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1);
                throw ex;
            }
        }
Ejemplo n.º 2
0
        private void FindExisitingpo(string ReqNo)
        {
            try
            {
                if (T_returnDL.ExistingT_return(ReqNo.Trim()))
                {
                    formMode = 3;
                    //clear datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    //clear error fields
                    errorProvider1.Clear();

                    t_return cat = new t_return();
                    cat.no = ReqNo.Trim();
                    T_returnDL dl = new T_returnDL();
                    cat = dl.Selectt_return(cat);

                    //set the process message and mode to edit mode
                    if (cat.isProcessed == false)
                    {
                        lbl_processes.Visible = false;
                        performButtons(xEnums.PerformanceType.Edit);
                    }
                    else
                    {
                        lbl_processes.Visible = true;
                    }

                    //load and disable the data fields

                    txt_locationId.Text = cat.locationId.Trim();
                    txt_supplierId.Text = cat.supplierId.Trim();
                    txt_remarks.Text    = cat.remarks;
                    dte_date.Value      = cat.date.Value;

                    textareaFunctions(false);

                    t_return_detail req = new t_return_detail();
                    req.returnNo = ReqNo.Trim();
                    T_return_detailDL      tdl      = new T_return_detailDL();
                    List <t_return_detail> requests = new List <t_return_detail>();
                    requests = tdl.SelectT_return_detailMulti(req);

                    foreach (t_return_detail det in requests)
                    {
                        commonFunctions.AddRow(dtx, det.productId, findExisting.FindExisitingStock(det.stockCode).Trim(), det.costPrice.ToString(), det.sellingPrice.ToString(), det.quantity.ToString(), det.amount.ToString());
                    }

                    txt_net.Text         = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_grossAmount.Text = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_noOfPeaces.Text  = commonFunctions.GetNoofPices(dataGridView1).ToString();
                    txt_noOfItems.Text   = commonFunctions.GetNoofItems(dataGridView1).ToString();
                }
                else
                {
                    if (formMode != 1)
                    {
                        errorProvider1.SetError(txt_no, "Request Number you have entered does not exists in the system.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                commonFunctions.SetMDIStatusMessage("Genaral Error", 1);
            }
        }
Ejemplo n.º 3
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            try
            {
                switch (xenum)
                {
                case xEnums.PerformanceType.View:
                    if (ActiveControl.Name.Trim() == txt_no.Name.Trim())
                    {
                        int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["POFieldLength"]);
                        string[] strSearchField = new string[length];

                        string strSQL = ConfigurationManager.AppSettings["POSQL"].ToString();

                        for (int i = 0; i < length; i++)
                        {
                            string m;
                            m = i.ToString();
                            strSearchField[i] = ConfigurationManager.AppSettings["POField" + m + ""].ToString();
                        }

                        frmU_Search find = new frmU_Search(strSQL, strSearchField, this);
                        find.ShowDialog(this);
                    }

                    break;

                case xEnums.PerformanceType.New:
                    FunctionButtonStatus(xEnums.PerformanceType.New);
                    formMode    = 1;
                    txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                    txt_no.Focus();

                    txt_locationId.Text      = commonFunctions.GlobalLocation;
                    txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_locationId.Text.Trim());

                    errorProvider1.Clear();

                    lbl_processes.Visible = false;
                    break;

                case xEnums.PerformanceType.Edit:
                    FunctionButtonStatus(xEnums.PerformanceType.Edit);
                    formMode = 3;
                    //txt_VehicleID.Enabled = false;
                    //txt_VehicleNo.Focus();
                    errorProvider1.Clear();
                    break;

                case xEnums.PerformanceType.Save:
                    errorProvider1.Clear();
                    if (formMode == 1)
                    {
                        if (!M_LocaDL.ExistingM_Loca(txt_locationId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_locationId, "Location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Location does not exists on the system", 1);
                            return;
                        }

                        if (!M_SupplierDL.ExistingM_Supplier(txt_supplierId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_supplierId, "Selected supplier does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Selected supplier does not exists on the system ", 1);
                            return;
                        }

                        if (commonFunctions.GetNoofItems(dataGridView1) <= 0)
                        {
                            errorProvider1.SetError(dataGridView1, "Please enter some items to the details grid");
                            commonFunctions.SetMDIStatusMessage("Please enter some items to the details grid", 1);
                            return;
                        }



                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            try
                            {
                                using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope())
                                {
                                    //u_DBConnection.BeginTrans();
                                    //save header data
                                    t_return objt_return = new t_return();
                                    objt_return.no          = txt_no.Text.Trim();
                                    objt_return.date        = dte_date.Value;
                                    objt_return.refNo       = txt_refNo.Text.Trim();
                                    objt_return.remarks     = txt_remarks.Text.Trim();
                                    objt_return.processDate = DateTime.Now;
                                    objt_return.processUser = "";
                                    objt_return.locationId  = commonFunctions.GlobalLocation;
                                    objt_return.supplierId  = txt_supplierId.Text.Trim();
                                    objt_return.noOfItems   = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim());
                                    objt_return.noOfPeaces  = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim());
                                    objt_return.grossAmount = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim());
                                    objt_return.isSaved     = true;
                                    objt_return.isProcessed = false;
                                    objt_return.GLUpdate    = false;
                                    objt_return.triggerVal  = 1;
                                    T_returnDL bal = new T_returnDL();
                                    bal.Savet_returnSP(objt_return, 1);


                                    //save details
                                    foreach (DataGridViewRow drow in dataGridView1.Rows)
                                    {
                                        if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                        {
                                            t_return_detail objt_return_detail = new t_return_detail();
                                            objt_return_detail.returnNo     = txt_no.Text.Trim();
                                            objt_return_detail.locationId   = commonFunctions.GlobalLocation;
                                            objt_return_detail.stockCode    = drow.Cells["Product Code"].Value.ToString();  //txt_stockCode.Text.Trim();
                                            objt_return_detail.productId    = StockEngine.GetProductCode(drow.Cells["Product Code"].Value.ToString());
                                            objt_return_detail.quantity     = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            objt_return_detail.amount       = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString());
                                            objt_return_detail.costPrice    = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                            objt_return_detail.sellingPrice = commonFunctions.ToDecimal(drow.Cells["Selling Price"].Value.ToString());
                                            objt_return_detail.triggerVal   = 1;
                                            T_return_detailDL bal2 = new T_return_detailDL();
                                            bal2.Savet_return_detailSP(objt_return_detail, 1);
                                        }
                                    }

                                    //increment the serial
                                    commonFunctions.IncrementSerial(formID);
                                    transaction.Complete();
                                    //u_DBConnection.CommitTrans();
                                    UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim());
                                }
                            }
                            catch (Exception ex)
                            {
                                // u_DBConnection.RollbackTrans();
                                LogFile.WriteErrorLog("Save Transactions", "PO", ex.Message);
                            }

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();
                                t_return objt_purchaseOrder2 = new t_return();
                                objt_purchaseOrder2.no = txt_no.Text.Trim();

                                T_returnDL balprocess = new T_returnDL();
                                objt_purchaseOrder2 = balprocess.Selectt_return(objt_purchaseOrder2);

                                objt_purchaseOrder2.isProcessed = true;
                                objt_purchaseOrder2.processDate = DateTime.Now;
                                objt_purchaseOrder2.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_returnSP(objt_purchaseOrder2, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());
                            }


                            //clear data in data grid
                            dtx.Rows.Clear();
                            dataGridView1.Refresh();
                            //clear text fields
                            textareaFunctions(true);

                            FunctionButtonStatus(xEnums.PerformanceType.Save);
                            //increment the serial
                            txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                            txt_supplierId.Focus();
                        }
                    }
                    else if (formMode == 3)
                    {
                        t_return cat = new t_return();
                        cat.no = txt_no.Text.Trim();
                        T_returnDL dl = new T_returnDL();
                        cat = dl.Selectt_return(cat);
                        if (cat.isProcessed == false)
                        {
                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_return objt_purchaseOrder2 = new t_return();
                                objt_purchaseOrder2.no = txt_no.Text.Trim();

                                T_returnDL balprocess = new T_returnDL();
                                objt_purchaseOrder2 = balprocess.Selectt_return(objt_purchaseOrder2);

                                objt_purchaseOrder2.isProcessed = true;
                                objt_purchaseOrder2.processDate = DateTime.Now;
                                objt_purchaseOrder2.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_returnSP(objt_purchaseOrder2, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());

                                //clear data in data grid
                                dtx.Rows.Clear();
                                dataGridView1.Refresh();
                                //clear text fields
                                textareaFunctions(true);
                                FunctionButtonStatus(xEnums.PerformanceType.Save);

                                txt_no.Text = commonFunctions.GetSerial(formID.Trim());
                                txt_supplierId.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_no, "Request Number you have entered already processed.");
                            commonFunctions.SetMDIStatusMessage("Request Number you have entered already processed.", 1);
                        }
                    }
                    break;

                case xEnums.PerformanceType.Cancel:
                    txt_no.Enabled = true;
                    FunctionButtonStatus(xEnums.PerformanceType.Default);
                    errorProvider1.Clear();
                    //clear text fields
                    textareaFunctions(true);
                    //clear Datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    txt_supplierId.Text = "";
                    txt_remarks.Text    = "";

                    lbl_processes.Visible = false;

                    break;

                case xEnums.PerformanceType.Print:
                    UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information);
                    break;
                }
            }
            catch (Exception ex)
            {
                LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1);
            }
        }