Beispiel #1
0
        /// <summary>
        /// Saves a record to the t_purchaseReq_detail table.
        /// </summary>
        public Boolean SaveT_purchaseReq_detailSP(t_purchaseReq_detail t_purchaseReq_detail, int formMode)
        {
            SqlCommand scom;
            bool       retvalue = false;

            try
            {
                scom             = new SqlCommand();
                scom.CommandType = CommandType.StoredProcedure;
                scom.CommandText = "T_purchaseReq_detailSave";

                scom.Parameters.Add("@purchaseReqNo", SqlDbType.VarChar, 20).Value = t_purchaseReq_detail.purchaseReqNo;
                scom.Parameters.Add("@locationId", SqlDbType.VarChar, 20).Value    = t_purchaseReq_detail.locationId;
                scom.Parameters.Add("@ReqDate", SqlDbType.DateTime, 8).Value       = t_purchaseReq_detail.ReqDate;
                scom.Parameters.Add("@deleveryDate", SqlDbType.DateTime, 8).Value  = t_purchaseReq_detail.deleveryDate;
                scom.Parameters.Add("@productId", SqlDbType.VarChar, 20).Value     = t_purchaseReq_detail.productId;
                scom.Parameters.Add("@description", SqlDbType.VarChar, 150).Value  = t_purchaseReq_detail.description;
                scom.Parameters.Add("@quantity", SqlDbType.Decimal, 9).Value       = t_purchaseReq_detail.quantity;
                scom.Parameters.Add("@costPrice", SqlDbType.Decimal, 9).Value      = t_purchaseReq_detail.costPrice;
                scom.Parameters.Add("@amount", SqlDbType.Decimal, 9).Value         = t_purchaseReq_detail.amount;
                scom.Parameters.Add("@release", SqlDbType.Int, 4).Value            = t_purchaseReq_detail.release;
                scom.Parameters.Add("@r_value", SqlDbType.Int, 4).Value            = t_purchaseReq_detail.r_value;
                scom.Parameters.Add("@triggerVal", SqlDbType.Int, 4).Value         = t_purchaseReq_detail.triggerVal;
                scom.Parameters.Add("@InsMode", SqlDbType.Int).Value  = formMode; // For insert
                scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0;

                u_DBConnection dbcon = new u_DBConnection();
                retvalue = dbcon.RunQuery(scom);
                return(retvalue);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Beispiel #2
0
        public List <t_purchaseReq_detail> Selectt_purchaseReq_detailMulti(t_purchaseReq_detail objt_purchaseReq_detail2)
        {
            List <t_purchaseReq_detail> retval = new List <t_purchaseReq_detail>();

            try
            {
                strquery = @"select * from T_purchaseReq_detail where purchaseReqNo = '" + objt_purchaseReq_detail2.purchaseReqNo + "'";
                DataTable dtt_purchaseReq_detail = u_DBConnection.ReturnDataTable(strquery, CommandType.Text);
                foreach (DataRow drType in dtt_purchaseReq_detail.Rows)
                {
                    if (drType != null)
                    {
                        t_purchaseReq_detail objt_purchaseReq_detail = new t_purchaseReq_detail();
                        objt_purchaseReq_detail.purchaseReqNo = drType["purchaseReqNo"].ToString();
                        objt_purchaseReq_detail.locationId    = drType["locationId"].ToString();
                        objt_purchaseReq_detail.ReqDate       = DateTime.Parse(drType["ReqDate"].ToString());
                        objt_purchaseReq_detail.deleveryDate  = DateTime.Parse(drType["deleveryDate"].ToString());
                        objt_purchaseReq_detail.productId     = drType["productId"].ToString();
                        objt_purchaseReq_detail.description   = drType["description"].ToString();
                        objt_purchaseReq_detail.quantity      = decimal.Parse(drType["quantity"].ToString());
                        objt_purchaseReq_detail.costPrice     = decimal.Parse(drType["costPrice"].ToString());
                        objt_purchaseReq_detail.amount        = decimal.Parse(drType["amount"].ToString());
                        objt_purchaseReq_detail.release       = int.Parse(drType["release"].ToString());
                        objt_purchaseReq_detail.r_value       = int.Parse(drType["r_value"].ToString());
                        objt_purchaseReq_detail.triggerVal    = int.Parse(drType["triggerVal"].ToString());
                        retval.Add(objt_purchaseReq_detail);
                    }
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
 public t_purchaseReq_detail Selectt_purchaseReq_detail(t_purchaseReq_detail objt_purchaseReq_detail)
 {
     try
     {
         strquery = @"select * from T_purchaseReq_detail where purchaseReqNo = '" + objt_purchaseReq_detail.purchaseReqNo + "'";
         DataRow drType = u_DBConnection.ReturnDataRow(strquery);
         if (drType != null)
         {
             objt_purchaseReq_detail.purchaseReqNo = drType["purchaseReqNo"].ToString();
             objt_purchaseReq_detail.locationId    = drType["locationId"].ToString();
             objt_purchaseReq_detail.ReqDate       = DateTime.Parse(drType["ReqDate"].ToString());
             objt_purchaseReq_detail.deleveryDate  = DateTime.Parse(drType["deleveryDate"].ToString());
             objt_purchaseReq_detail.productId     = drType["productId"].ToString();
             objt_purchaseReq_detail.description   = drType["description"].ToString();
             objt_purchaseReq_detail.quantity      = decimal.Parse(drType["quantity"].ToString());
             objt_purchaseReq_detail.costPrice     = decimal.Parse(drType["costPrice"].ToString());
             objt_purchaseReq_detail.amount        = decimal.Parse(drType["amount"].ToString());
             objt_purchaseReq_detail.release       = int.Parse(drType["release"].ToString());
             objt_purchaseReq_detail.r_value       = int.Parse(drType["r_value"].ToString());
             objt_purchaseReq_detail.triggerVal    = int.Parse(drType["triggerVal"].ToString());
             return(objt_purchaseReq_detail);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        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);
            }
        }
        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);
            }
        }