示例#1
0
 private void SetValues(String sm_Loca)
 {
     try
     {
         M_LocaDL objm_LocaDL = new M_LocaDL();
         M_Loca   objm_Loca   = new M_Loca();
         if (sm_Loca != "")
         {
             objm_Loca.Locacode = sm_Loca;
             objm_Loca          = objm_LocaDL.Selectm_Loca(objm_Loca);
             if (objm_Loca != null)
             {
                 txt_Locacode.Text = objm_Loca.Locacode.ToString();
                 txt_Locaname.Text = objm_Loca.Companycode.ToString();
                 //txt_StockCode.Text = objm_Loca.StockCode.ToString();
                 txt_Locaname.Text = objm_Loca.Locaname.ToString();
                 txt_Add1.Text     = objm_Loca.Add1.ToString();
                 txt_Add2.Text     = objm_Loca.Add2.ToString();
                 txt_Add3.Text     = objm_Loca.Add3.ToString();
                 txt_Tpno.Text     = objm_Loca.Tpno.ToString();
                 txt_Fax.Text      = objm_Loca.Fax.ToString();
                 txt_Emailx.Text   = objm_Loca.Emailx.ToString();
                 //txt_Userx.Text = objm_Loca.Userx.ToString();
                 //txt_Datex.Text = objm_Loca.Datex.ToString();
                 formMode = 3;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
        private void GetData()
        {
            try
            {
                M_LocaDL bdl = new M_LocaDL();
                dataGridView1.DataSource = bdl.SelectAllm_Loca();

                if (dataGridView1.DataSource != null)
                {
                    dataGridView1.Columns[0].HeaderText = "Location Code";
                    dataGridView1.Columns[1].HeaderText = "Location Name";

                    dataGridView1.Columns[0].Width = 180;
                    dataGridView1.Columns[1].Width = 525;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void FindExisitingLoca(string locacode)
 {
     try{
         if (M_LocaDL.ExistingM_Loca(locacode.Trim()))
         {
             M_Loca cat = new M_Loca();
             cat.Locacode = locacode.Trim();
             M_LocaDL dl = new M_LocaDL();
             cat = dl.Selectm_Loca(cat);
             txt_location.Text = cat.Locacode.Trim();
             txt_locaname.Text = cat.Locaname;
         }
         else
         {
             txt_locaname.Text = "<Location Not Exists.>";
         }
     }
     catch (Exception ex)
     {
         LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
         commonFunctions.SetMDIStatusMessage("Genaral Error", 1);
     }
 }
        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_sourceLocId.Text     = commonFunctions.GlobalLocation;
                    txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_sourceLocId.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 (txt_sourceLocId.Text.Trim().ToUpper() == txt_destinationLocId.Text.Trim().ToUpper())
                        {
                            errorProvider1.SetError(txt_destinationLocId, "Destination location cannot same as login location");
                            return;
                        }


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


                        if (!M_LocaDL.ExistingM_Loca(txt_destinationLocId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_destinationLocId, "Destination Location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Destination Location 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_trnsferInNote objt_trnsferInNote = new t_trnsferInNote();
                                    objt_trnsferInNote.transinNo        = txt_no.Text.Trim();
                                    objt_trnsferInNote.sourceLocId      = commonFunctions.GlobalLocation;
                                    objt_trnsferInNote.date             = dte_date.Value;
                                    objt_trnsferInNote.refNo            = txt_refNo.Text.Trim();
                                    objt_trnsferInNote.remarks          = txt_remarks.Text.Trim();
                                    objt_trnsferInNote.destinationLocId = txt_destinationLocId.Text.Trim();
                                    objt_trnsferInNote.purchaseReqNo    = txt_purchaseReqNo.Text.Trim();
                                    objt_trnsferInNote.noOfItems        = commonFunctions.ToDecimal(txt_noOfItems.Text.Trim());
                                    objt_trnsferInNote.noOfPeaces       = commonFunctions.ToDecimal(txt_noOfPeaces.Text.Trim());
                                    objt_trnsferInNote.grossAmount      = commonFunctions.ToDecimal(txt_grossAmount.Text.Trim());
                                    objt_trnsferInNote.isProcessed      = false;
                                    objt_trnsferInNote.processDate      = DateTime.Now;
                                    objt_trnsferInNote.processUser      = "";
                                    objt_trnsferInNote.GLUpdate         = false;
                                    objt_trnsferInNote.triggerVal       = 1;
                                    T_trnsferInNoteDL bal = new T_trnsferInNoteDL();
                                    bal.Savet_trnsferInNoteSP(objt_trnsferInNote, 1);


                                    //save details
                                    foreach (DataGridViewRow drow in dataGridView1.Rows)
                                    {
                                        if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                        {
                                            t_transferIn_detail objt_transferIn_detail = new t_transferIn_detail();
                                            objt_transferIn_detail.transinrNo       = txt_no.Text.Trim();
                                            objt_transferIn_detail.sourceLocId      = commonFunctions.GlobalLocation;
                                            objt_transferIn_detail.destinationLocId = txt_destinationLocId.Text.Trim();
                                            objt_transferIn_detail.transferDate     = dte_date.Value;
                                            objt_transferIn_detail.stockCode        = drow.Cells["Product Code"].Value.ToString();
                                            objt_transferIn_detail.description      = drow.Cells["Product Name"].Value.ToString();
                                            objt_transferIn_detail.quantity         = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            objt_transferIn_detail.costPrice        = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                            objt_transferIn_detail.amount           = commonFunctions.ToDecimal(drow.Cells["Amount"].Value.ToString());
                                            objt_transferIn_detail.triggerVal       = 1;
                                            T_transferIn_detailDL bal2 = new T_transferIn_detailDL();
                                            bal2.Savet_transferIn_detailSP(objt_transferIn_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", "Transfer In", ex.Message);
                                LogFile.WriteErrorLog("Save Transactions", "Transfer Out", ex.Message);
                                commonFunctions.SetMDIStatusMessage("Transfer Number you have entered already processed", 1);
                            }

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_trnsferInNote objt_trnsferNote = new t_trnsferInNote();
                                objt_trnsferNote.transinNo = txt_no.Text.Trim();

                                T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL();
                                objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_trnsferInNoteSP(objt_trnsferNote, 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_trnsferInNote cat = new t_trnsferInNote();
                        cat.transinNo = txt_no.Text.Trim();
                        T_trnsferInNoteDL dl = new T_trnsferInNoteDL();
                        cat = dl.Selectt_trnsferInNote(cat);
                        if (cat.isProcessed == false)
                        {
                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_trnsferInNote objt_trnsferNote = new t_trnsferInNote();
                                objt_trnsferNote.transinNo = txt_no.Text.Trim();

                                T_trnsferInNoteDL balprocess = new T_trnsferInNoteDL();
                                objt_trnsferNote = balprocess.Selectt_trnsferInNote(objt_trnsferNote);

                                objt_trnsferNote.isProcessed = true;
                                objt_trnsferNote.processDate = DateTime.Now;
                                objt_trnsferNote.processUser = commonFunctions.Loginuser;
                                balprocess.Savet_trnsferInNoteSP(objt_trnsferNote, 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_refNo.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_no, "Transfer IN Number you have entered already processed.");
                        }
                    }
                    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 loading data", 1);
            }
        }
        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);
            }
        }
示例#6
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_sourceLocId.Text     = commonFunctions.GlobalLocation;
                    txt_locationId_name.Text = findExisting.FindExisitingLoca(txt_sourceLocId.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_sourceLocId.Text.Trim()))
                        {
                            errorProvider1.SetError(txt_sourceLocId, "Location does not exists on the system ");
                            commonFunctions.SetMDIStatusMessage("Location 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_adjustment_head objt_adjustment_head = new t_adjustment_head();

                                    objt_adjustment_head.adju_no       = txt_no.Text.Trim();
                                    objt_adjustment_head.location_id   = commonFunctions.GlobalLocation;
                                    objt_adjustment_head.adjsment_date = dte_date.Value;
                                    objt_adjustment_head.remarks       = txt_remarks.Text.Trim();
                                    objt_adjustment_head.user_id       = commonFunctions.Loginuser;
                                    objt_adjustment_head.batch_no      = txt_batch_no.Text.Trim();
                                    objt_adjustment_head.process       = false;
                                    objt_adjustment_head.process_user  = commonFunctions.Loginuser;
                                    objt_adjustment_head.process_date  = DateTime.Now;
                                    objt_adjustment_head.triggerVal    = 1;
                                    T_adjustment_headDL bal = new T_adjustment_headDL();
                                    bal.Savet_adjustment_headSP(objt_adjustment_head, 1);


                                    //save details
                                    foreach (DataGridViewRow drow in dataGridView1.Rows)
                                    {
                                        if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                        {
                                            //have to implement the logic. this is only saving the data to the system
                                            t_adjustment_details objt_adjustment_detail = new t_adjustment_details();
                                            objt_adjustment_detail.adju_no           = txt_no.Text.Trim();
                                            objt_adjustment_detail.location_id       = commonFunctions.GlobalLocation;
                                            objt_adjustment_detail.line_no           = 1;
                                            objt_adjustment_detail.item_code         = drow.Cells["Product Code"].Value.ToString();
                                            objt_adjustment_detail.cost              = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                            objt_adjustment_detail.stock             = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            objt_adjustment_detail.physical_quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());    //txt_physical_quantity.Text.Trim();
                                            objt_adjustment_detail.variance          = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                            if (rdo_add.Checked)
                                            {
                                                objt_adjustment_detail.triggerVal = 1;
                                            }
                                            if (rdo_reduce.Checked)
                                            {
                                                objt_adjustment_detail.triggerVal = 2;
                                            }
                                            T_adjustment_detailDL bal2 = new T_adjustment_detailDL();
                                            bal2.Savet_adjustment_detailSP(objt_adjustment_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(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception");
                                commonFunctions.SetMDIStatusMessage("Genaral Error on loading data", 1);
                            }

                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                UpdateStock();

                                t_adjustment_head objt_trnsferNote = new t_adjustment_head();
                                objt_trnsferNote.adju_no = txt_no.Text.Trim();

                                T_adjustment_headDL balprocess = new T_adjustment_headDL();
                                objt_trnsferNote = balprocess.Selectt_adjustment_head(objt_trnsferNote);

                                objt_trnsferNote.process      = true;
                                objt_trnsferNote.process_date = DateTime.Now;
                                objt_trnsferNote.process_user = commonFunctions.Loginuser;
                                balprocess.Savet_adjustment_headSP(objt_trnsferNote, 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_adjustment_head cat = new t_adjustment_head();
                        cat.adju_no = txt_no.Text.Trim();
                        T_adjustment_headDL dl = new T_adjustment_headDL();
                        cat = dl.Selectt_adjustment_head(cat);
                        if (cat.process == false)
                        {
                            if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                            {
                                cat.location_id   = txt_sourceLocId.Text.Trim();
                                cat.adjsment_date = dte_date.Value;
                                cat.remarks       = txt_remarks.Text.Trim();
                                cat.user_id       = commonFunctions.Loginuser;
                                cat.batch_no      = txt_batch_no.Text.Trim();
                                new T_adjustment_headDL().Savet_adjustment_headSP(cat, 3);

                                List <t_adjustment_details> detsx = new List <t_adjustment_details>();
                                t_adjustment_details        detx  = new t_adjustment_details();
                                detx.adju_no = cat.adju_no.Trim();
                                detsx        = new T_adjustment_detailDL().SelectT_adjustment_detailMulti(detx);
                                foreach (t_adjustment_details det in detsx)
                                {
                                    new T_adjustment_detailDL().Savet_adjustment_detailSP(det, 4);
                                }
                                //save details
                                foreach (DataGridViewRow drow in dataGridView1.Rows)
                                {
                                    if (drow.Cells["Product Code"].Value.ToString().Trim() != null)
                                    {
                                        //have to implement the logic. this is only saving the data to the system
                                        t_adjustment_details objt_adjustment_detail = new t_adjustment_details();
                                        objt_adjustment_detail.adju_no           = txt_no.Text.Trim();
                                        objt_adjustment_detail.location_id       = txt_sourceLocId.Text.Trim();
                                        objt_adjustment_detail.line_no           = 1;
                                        objt_adjustment_detail.item_code         = drow.Cells["Product Code"].Value.ToString();
                                        objt_adjustment_detail.cost              = commonFunctions.ToDecimal(drow.Cells["Cost Price"].Value.ToString());
                                        objt_adjustment_detail.stock             = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                        objt_adjustment_detail.physical_quantity = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());    //txt_physical_quantity.Text.Trim();
                                        objt_adjustment_detail.variance          = commonFunctions.ToDecimal(drow.Cells["Quntity"].Value.ToString());
                                        if (rdo_add.Checked)
                                        {
                                            objt_adjustment_detail.triggerVal = 1;
                                        }
                                        if (rdo_reduce.Checked)
                                        {
                                            objt_adjustment_detail.triggerVal = 2;
                                        }
                                        T_adjustment_detailDL bal2 = new T_adjustment_detailDL();
                                        bal2.Savet_adjustment_detailSP(objt_adjustment_detail, 1);
                                    }
                                }

                                if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Process, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                                {
                                    cat.process      = true;
                                    cat.process_date = DateTime.Now;
                                    cat.process_user = commonFunctions.Loginuser;
                                    new T_adjustment_headDL().Savet_adjustment_headSP(cat, 3);
                                    UpdateStock();
                                }

                                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_code.Focus();
                            }
                        }
                        else
                        {
                            errorProvider1.SetError(txt_no, "Adjustment Number you have entered already processed.");
                            commonFunctions.SetMDIStatusMessage("Adjustment 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);
            }
        }
示例#7
0
        private void performButtons(xEnums.PerformanceType xenum)
        {
            switch (xenum)
            {
            case xEnums.PerformanceType.View:

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

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

                    for (int i = 0; i < length; i++)
                    {
                        string m;
                        m = i.ToString();
                        strSearchField[i] = ConfigurationManager.AppSettings["BankField" + 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_Locacode.Focus();
                break;

            case xEnums.PerformanceType.Edit:
                FunctionButtonStatus(xEnums.PerformanceType.Edit);
                formMode             = 3;
                txt_Locacode.Enabled = false;
                txt_Locaname.Focus();
                break;

            case xEnums.PerformanceType.Save:

                if (formMode == 1)
                {
                    if (M_LocaDL.ExistingM_Loca(txt_Locacode.Text.Trim()))
                    {
                        UserDefineMessages.ShowMsg("The location code you have entered already exists!", UserDefineMessages.Msg_Warning);
                        return;
                    }

                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_Loca objm_Loca = new M_Loca();
                        objm_Loca.Locacode    = txt_Locacode.Text.Trim();
                        objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim();
                        objm_Loca.StockCode   = txt_Locacode.Text.Trim();
                        objm_Loca.Locaname    = txt_Locaname.Text.Trim();
                        objm_Loca.Add1        = txt_Add1.Text.Trim();
                        objm_Loca.Add2        = txt_Add2.Text.Trim();
                        objm_Loca.Add3        = txt_Add3.Text.Trim();
                        objm_Loca.Tpno        = txt_Tpno.Text.Trim();
                        objm_Loca.Fax         = txt_Fax.Text.Trim();
                        objm_Loca.Emailx      = txt_Emailx.Text.Trim();
                        objm_Loca.Userx       = commonFunctions.Loginuser;
                        objm_Loca.Datex       = DateTime.Now;
                        M_LocaDL bal = new M_LocaDL();
                        bal.SaveM_LocaSP(objm_Loca, 1);
                        GetData();

                        txt_Locacode.Enabled = true;
                        FunctionButtonStatus(xEnums.PerformanceType.Save);
                        commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2);
                    }
                }
                else if (formMode == 3)
                {
                    if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes)
                    {
                        M_Loca objm_Loca = new M_Loca();
                        objm_Loca.Locacode    = txt_Locacode.Text.Trim();
                        objm_Loca.Companycode = commonFunctions.GlobalCompany.Trim();
                        objm_Loca.StockCode   = txt_Locacode.Text.Trim();
                        objm_Loca.Locaname    = txt_Locaname.Text.Trim();
                        objm_Loca.Add1        = txt_Add1.Text.Trim();
                        objm_Loca.Add2        = txt_Add2.Text.Trim();
                        objm_Loca.Add3        = txt_Add3.Text.Trim();
                        objm_Loca.Tpno        = txt_Tpno.Text.Trim();
                        objm_Loca.Fax         = txt_Fax.Text.Trim();
                        objm_Loca.Emailx      = txt_Emailx.Text.Trim();
                        objm_Loca.Userx       = commonFunctions.Loginuser;
                        objm_Loca.Datex       = DateTime.Now;
                        M_LocaDL bal = new M_LocaDL();
                        bal.SaveM_LocaSP(objm_Loca, 3);

                        GetData();
                        txt_Locacode.Enabled = true;
                        FunctionButtonStatus(xEnums.PerformanceType.Save);
                        commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2);
                    }
                }
                break;

            case xEnums.PerformanceType.Cancel:
                txt_Locacode.Enabled = true;
                FunctionButtonStatus(xEnums.PerformanceType.Default);
                break;

            case xEnums.PerformanceType.Print:
                UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information);
                break;
            }
        }