コード例 #1
0
        private void FindExisitingRequests(string ReqNo)
        {
            try{
                if (T_purchaseRequisitionDL.ExistingT_purchaseRequisition(ReqNo.Trim()))
                {
                    formMode = 3;
                    //clear datagrid
                    dtx.Clear();
                    dataGridView1.Refresh();

                    //clear error fields
                    errorProvider1.Clear();

                    t_purchaseRequisition cat = new t_purchaseRequisition();
                    cat.no = ReqNo.Trim();
                    T_purchaseRequisitionDL dl = new T_purchaseRequisitionDL();
                    cat = dl.Selectt_purchaseRequisition(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_location.Text = cat.locationId.Trim();
                    txt_Suplier.Text  = cat.supplierId.Trim();
                    txt_remark.Text   = cat.remarks;

                    txt_Suplier.Enabled   = false;
                    txt_location.Enabled  = false;
                    txt_remark.Enabled    = false;
                    dataGridView1.Enabled = false;

                    t_purchaseReq_detail req = new t_purchaseReq_detail();
                    req.purchaseReqNo = ReqNo.Trim();
                    T_purchaseReq_detailDL      tdl      = new T_purchaseReq_detailDL();
                    List <t_purchaseReq_detail> requests = new List <t_purchaseReq_detail>();
                    requests = tdl.Selectt_purchaseReq_detailMulti(req);

                    foreach (t_purchaseReq_detail det in requests)
                    {
                        commonFunctions.AddRow(dtx, det.productId, det.description, det.costPrice.ToString(), M_ProductDL.GetSellingPrice(det.productId).ToString(), det.quantity.ToString(), det.amount.ToString());
                    }

                    txt_net.Text   = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_gross.Text = commonFunctions.GetGrossAmount(dataGridView1).ToString();
                    txt_pices.Text = commonFunctions.GetNoofPices(dataGridView1).ToString();
                    txt_items.Text = commonFunctions.GetNoofItems(dataGridView1).ToString();

                    //txt_locaname.Text = cat.Locaname;
                }
                else
                {
                    if (formMode != 1)
                    {
                        errorProvider1.SetError(txt_reqno, "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);
            }
        }
コード例 #2
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            try
            {
                switch (xenum)
                {
                case xEnums.PerformanceType.View:

                    if (ActiveControl.Name.Trim() == txt_reqno.Name.Trim())
                    {
                        int      length         = Convert.ToInt32(ConfigurationManager.AppSettings["PurreqFieldLength"]);
                        string[] strSearchField = new string[length];

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

                        for (int i = 0; i < length; i++)
                        {
                            string m;
                            m = i.ToString();
                            strSearchField[i] = ConfigurationManager.AppSettings["VehicleField" + 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_reqno.Text = commonFunctions.GetSerial(formID.Trim());

                    txt_reqno.Focus();
                    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 (T_purchaseRequisitionDL.ExistingT_purchaseRequisition(txt_reqno.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_reqno, "Selected request No already exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Selected request No already exists on the system ", 1);
                            return;
                        }

                        if (!M_LocaDL.ExistingM_Loca(txt_location.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_location, "Selected location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Selected location does not exists on the system", 1);
                            return;
                        }

                        if (!M_SupplierDL.ExistingM_Supplier(txt_Suplier.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_Suplier, "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 (DateTime.Compare(dte_request.Value, dte_dilivary.Value) > -1)
                        {
                            errorProvider1.SetError(dte_dilivary, "Delivary date must be grater than request date");
                            commonFunctions.SetMDIStatusMessage("Delivary date must be grater than request date ", 1);
                            return;
                        }


                        if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                        {
                            using (TransactionScope transaction = new TransactionScope())
                            {
                                //save header data
                                t_purchaseRequisition objt_purchaseRequisition = new t_purchaseRequisition();
                                objt_purchaseRequisition.no           = txt_reqno.Text.Trim();
                                objt_purchaseRequisition.date         = dte_request.Value;
                                objt_purchaseRequisition.deleveryDate = dte_dilivary.Value;
                                objt_purchaseRequisition.remarks      = txt_remark.Text.Trim();
                                objt_purchaseRequisition.processDate  = DateTime.Now;
                                objt_purchaseRequisition.processUser  = "";
                                objt_purchaseRequisition.locationId   = commonFunctions.GlobalLocation;
                                objt_purchaseRequisition.supplierId   = txt_Suplier.Text.Trim();
                                objt_purchaseRequisition.noOfItems    = commonFunctions.ToDecimal(txt_items.Text.Trim());
                                objt_purchaseRequisition.noOfPeaces   = commonFunctions.ToDecimal(txt_pices.Text.Trim());
                                objt_purchaseRequisition.grossAmount  = commonFunctions.ToDecimal(txt_gross.Text.Trim());
                                objt_purchaseRequisition.isSaved      = true;
                                objt_purchaseRequisition.isProcessed  = false;
                                objt_purchaseRequisition.triggerVal   = 1;
                                T_purchaseRequisitionDL bal = new T_purchaseRequisitionDL();
                                bal.SaveT_purchaseRequisitionSP(objt_purchaseRequisition, 1);

                                //save details
                                foreach (DataGridViewRow drow in dataGridView1.Rows)
                                {
                                    if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                    {
                                        t_purchaseReq_detail objt_purchaseReq_detail = new t_purchaseReq_detail();
                                        objt_purchaseReq_detail.purchaseReqNo = txt_reqno.Text.Trim();
                                        objt_purchaseReq_detail.locationId    = commonFunctions.GlobalLocation;
                                        objt_purchaseReq_detail.ReqDate       = dte_request.Value;
                                        objt_purchaseReq_detail.deleveryDate  = dte_dilivary.Value;
                                        objt_purchaseReq_detail.productId     = drow.Cells["Product Code"].Value.ToString();
                                        objt_purchaseReq_detail.description   = drow.Cells["Product Name"].Value.ToString();
                                        objt_purchaseReq_detail.quantity      = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                        objt_purchaseReq_detail.costPrice     = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                        objt_purchaseReq_detail.amount        = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString());
                                        objt_purchaseReq_detail.release       = 0;
                                        objt_purchaseReq_detail.r_value       = 0;
                                        objt_purchaseReq_detail.triggerVal    = 0;
                                        T_purchaseReq_detailDL bal2 = new T_purchaseReq_detailDL();
                                        bal2.SaveT_purchaseReq_detailSP(objt_purchaseReq_detail, 1);
                                    }
                                }

                                //increment the serial
                                commonFunctions.IncrementSerial(formID);
                                transaction.Complete();
                            }

                            UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim());

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                t_purchaseRequisition objt_purchaseRequisitionxc = new t_purchaseRequisition();
                                objt_purchaseRequisitionxc.no = txt_reqno.Text.Trim();

                                T_purchaseRequisitionDL bal2 = new T_purchaseRequisitionDL();
                                objt_purchaseRequisitionxc             = bal2.Selectt_purchaseRequisition(objt_purchaseRequisitionxc);
                                objt_purchaseRequisitionxc.isProcessed = true;
                                objt_purchaseRequisitionxc.processDate = DateTime.Now;
                                objt_purchaseRequisitionxc.processUser = commonFunctions.Loginuser;
                                bal2.SaveT_purchaseRequisitionSP(objt_purchaseRequisitionxc, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());
                            }


                            //clear data in data grid
                            dtx.Rows.Clear();
                            dataGridView1.Refresh();
                            //clear text fields
                            txt_Suplier.Text      = "";
                            txt_suppliername.Text = "";
                            txt_location.Text     = "";
                            txt_locaname.Text     = "";
                            txt_remark.Text       = "";

                            txt_code.Text    = "";
                            txt_cost.Text    = "0.00";
                            txt_selling.Text = "0.00";
                            txt_qty.Text     = "0.00";
                            txt_amt.Text     = "0.00";


                            txt_reqno.Enabled     = true;
                            txt_Suplier.Enabled   = true;
                            txt_location.Enabled  = true;
                            txt_remark.Enabled    = true;
                            dataGridView1.Enabled = true;

                            FunctionButtonStatus(xEnums.PerformanceType.Save);
                            //increment the serial
                            txt_reqno.Text = commonFunctions.GetSerial(formID.Trim());
                            txt_location.Focus();
                        }
                    }
                    else if (formMode == 3)
                    {
                        t_purchaseRequisition cat = new t_purchaseRequisition();
                        cat.no = txt_reqno.Text.Trim();
                        T_purchaseRequisitionDL dl = new T_purchaseRequisitionDL();
                        cat = dl.Selectt_purchaseRequisition(cat);
                        if (cat.isProcessed == false)
                        {
                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                t_purchaseRequisition objt_purchaseRequisitionxc = new t_purchaseRequisition();
                                objt_purchaseRequisitionxc.no = txt_reqno.Text.Trim();

                                T_purchaseRequisitionDL bal2 = new T_purchaseRequisitionDL();
                                objt_purchaseRequisitionxc             = bal2.Selectt_purchaseRequisition(objt_purchaseRequisitionxc);
                                objt_purchaseRequisitionxc.isProcessed = true;
                                objt_purchaseRequisitionxc.processDate = DateTime.Now;
                                objt_purchaseRequisitionxc.processUser = commonFunctions.Loginuser;
                                bal2.SaveT_purchaseRequisitionSP(objt_purchaseRequisitionxc, 3);
                                UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Update_Sucess, commonFunctions.Softwarename.Trim());



                                //clear data in data grid
                                dtx.Rows.Clear();
                                dataGridView1.Refresh();
                                //clear text fields
                                txt_Suplier.Text      = "";
                                txt_suppliername.Text = "";
                                txt_location.Text     = "";
                                txt_locaname.Text     = "";
                                txt_remark.Text       = "";

                                txt_reqno.Enabled     = true;
                                txt_Suplier.Enabled   = true;
                                txt_location.Enabled  = true;
                                txt_remark.Enabled    = true;
                                dataGridView1.Enabled = true;

                                FunctionButtonStatus(xEnums.PerformanceType.Save);
                                //increment the serial
                                txt_reqno.Text = commonFunctions.GetSerial(formID.Trim());
                                txt_location.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_reqno, "Request Number you have entered already processed.");
                            commonFunctions.SetMDIStatusMessage("Request Number you have entered already processed.", 1);
                        }
                    }
                    break;

                case xEnums.PerformanceType.Cancel:
                    txt_reqno.Enabled = true;
                    FunctionButtonStatus(xEnums.PerformanceType.Default);
                    errorProvider1.Clear();
                    txt_Suplier.Enabled   = true;
                    txt_location.Enabled  = true;
                    txt_remark.Enabled    = true;
                    dataGridView1.Enabled = true;

                    dtx.Clear();
                    dataGridView1.Refresh();
                    txt_Suplier.Text  = "";
                    txt_location.Text = "";
                    txt_remark.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);
            }
        }