예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string str = MessageBox.Show("Are you want to delete this Company", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).ToString();

            if (str.Equals("Yes"))
            {
                SQLHelper      objSQLHelper      = new SQLHelper();
                SqlTransaction objSqlTransaction = objSQLHelper.BeginTrans();
                try
                {
                    PurchaseOrderDL objPurchasesOrderDL = new PurchaseOrderDL();
                    List <PurchasesOrderDetailEL> lstPurchasesOrderDetailEL = new List <PurchasesOrderDetailEL>();
                    PurchasesOrderDetailDL        objPurchasesOrderDetailDL = new PurchasesOrderDetailDL();

                    int PurchasesOrderId = SelectedPurchasesOrder.Purchases_Order_Id;
                    lstPurchasesOrderDetailEL = objPurchasesOrderDetailDL.GetPurchasesOrderDetailByOrderId(PurchasesOrderId);
                    lstPurchasesOrderDetailEL.ForEach(r => objPurchasesOrderDetailDL.Delete(objSqlTransaction, r));
                    objPurchasesOrderDL.Delete(objSqlTransaction, SelectedPurchasesOrder);

                    objSqlTransaction.Commit();
                    Common.MessageDelete();
                    FillListBox();
                    ControlClear();
                }
                catch
                {
                    objSqlTransaction.Rollback();
                }
            }
        }
        private void GetPurchaseOrderDetails(int PurchaseOrderID)
        {
            try
            {
                PurchaseOrderDL _currentPurchaseOrder = new PurchaseOrderDL();
                _currentPurchaseOrder.GetPurchaseOrderByPurchaseOrderID(Convert.ToInt32(hfPurchaseOrderID.Value.ToString()));

                ddlContact.SelectedValue  = _currentPurchaseOrder.BuyerID.ToString();
                txtPONO.Text              = _currentPurchaseOrder.PurchaseOrderNo;
                txtPODate.Text            = _currentPurchaseOrder.PurchaseOrderDate.ToString();
                ddlCurrency.SelectedValue = _currentPurchaseOrder.Currency;
                ddlShipment.SelectedValue = _currentPurchaseOrder.Shipment;
                txtTel.Text       = _currentPurchaseOrder.TelNo;
                lblTotalCost.Text = _currentPurchaseOrder.GrandTotal.ToString();

                if (hfPurchaseOrderID.Value.ToString() != "0")
                {
                    trEnablePurchaseWorkOrder.Visible = true;
                }

                _currentPurchaseWorkOrder = new PurchaseWorkOrderDL();

                gvPurchaseWorkOrder.DataSource = _currentPurchaseWorkOrder.GetPurchaseWorkOrderByPurchaseOrderID(Convert.ToInt32(hfPurchaseOrderID.Value.ToString())).Tables[0];
                gvPurchaseWorkOrder.DataBind();
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("AddEditPurchaseOrder.aspx", "", "GetPurchaseOrderDetails(int PurchaseOrderID)", ex.Message, new ACEConnection());
            }
        }
예제 #3
0
        void FillListBox()
        {
            dataGridView1.Rows.Clear();
            try
            {
                PurchaseOrderDL        objPurchaseOrderDL       = new PurchaseOrderDL();
                List <PurchaseOrderEL> lstPurchaseOrderEL       = objPurchaseOrderDL.GetPurchasesOrderByComId(companyEL.Company_id);
                List <int>             lstCompletePurchaseOrder = objPurchaseOrderDL.GetCompletePurchasesOrder(companyEL.Company_id);

                ListPurchaseOrder.SelectionChanged -= ListPurchaseOrder_SelectedIndexChanged;
                for (int i = 0; i < lstPurchaseOrderEL.Count; i++)
                {
                    ListPurchaseOrder.Rows.Add();
                    ListPurchaseOrder.Rows[i].Cells["Purchases_Order_Id"].Value = lstPurchaseOrderEL[i].Purchases_Order_Id;
                    ListPurchaseOrder.Rows[i].Cells["Company_id"].Value         = lstPurchaseOrderEL[i].Company_id;
                    ListPurchaseOrder.Rows[i].Cells["Date"].Value = lstPurchaseOrderEL[i].Date.ToString("dd-MM-yyyy");
                    ListPurchaseOrder.Rows[i].Cells["Purchases_Order_No"].Value = lstPurchaseOrderEL[i].Purchases_Order_No;
                    if (lstCompletePurchaseOrder.Exists(r => lstPurchaseOrderEL[i].Purchases_Order_Id == r))
                    {
                        ListPurchaseOrder.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Green;
                        ListPurchaseOrder.Rows[i].DefaultCellStyle.ForeColor = System.Drawing.Color.White;
                    }
                }
                //GridBind();
                ListPurchaseOrder.SelectionChanged += ListPurchaseOrder_SelectedIndexChanged;
            }
            catch
            {
            }
        }
예제 #4
0
        void GridBind()
        {
            dataGridView1.Rows.Clear();
            try
            {
                int             PurchasesOrderId   = Convert.ToInt32(ListPurchaseOrder.SelectedRows[0].Cells["Purchases_Order_Id"].Value);
                PurchaseOrderDL objPurchaseOrderDL = new PurchaseOrderDL();
                DataTable       dt = objPurchaseOrderDL.GetBalanceSheet(PurchasesOrderId);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1.Rows[i].Cells["Purchase_Order_Detail_Id"].Value = dt.Rows[i]["Purchase_Order_Detail_Id"];
                        dataGridView1.Rows[i].Cells["Item_Name"].Value              = dt.Rows[i]["Item_Name"];
                        dataGridView1.Rows[i].Cells["Item_Quantity"].Value          = dt.Rows[i]["Item_Quantity"];
                        dataGridView1.Rows[i].Cells["Item_Rate"].Value              = dt.Rows[i]["Item_Rate"];
                        dataGridView1.Rows[i].Cells["Total_Amount"].Value           = dt.Rows[i]["Total_Amount"];
                        dataGridView1.Rows[i].Cells["Total_Deliver_Quantity"].Value = dt.Rows[i]["Total_Deliver_Quantity"];
                        dataGridView1.Rows[i].Cells["Total_Balance"].Value          = Convert.ToInt32(dt.Rows[i]["Total_Balance"]) * -1;
                    }
                }
            }
            catch
            {
            }
        }
예제 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (textPuchasesOrderNo.Text.Trim() == "")
            {
                Common.MessageAlert("First enter Purchases Order No");
                return;
            }
            if (dataGridView1.Rows.Count - 1 <= 0)
            {
                Common.MessageAlert("First Enter Item Detail");
                return;
            }

            SQLHelper      objSQLHelper      = new SQLHelper();
            SqlTransaction objSqlTransaction = objSQLHelper.BeginTrans();

            try
            {
                PurchaseOrderEL               objPurchaseOrderEL  = new PurchaseOrderEL();
                PurchaseOrderDL               objPurchasesOrderDL = new PurchaseOrderDL();
                PurchasesOrderDetailEL        objPurchasesOrderDetailEL;
                List <PurchasesOrderDetailEL> lstPurchasesOrderDetailEL = new List <PurchasesOrderDetailEL>();
                PurchasesOrderDetailDL        objPurchasesOrderDetailDL = new PurchasesOrderDetailDL();

                objPurchaseOrderEL.Company_id         = companyEL.Company_id;
                objPurchaseOrderEL.Date               = dateTimePickerPurchasesOrderDate.Value;
                objPurchaseOrderEL.Purchases_Order_No = textPuchasesOrderNo.Text.Trim();
                int PurchaseOrderId = objPurchasesOrderDL.Insert(objSqlTransaction, objPurchaseOrderEL);


                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    objPurchasesOrderDetailEL = new PurchasesOrderDetailEL();
                    //objPurchasesOrderDetailEL.Item_Name = dataGridView1.Rows[i].Cells["Item_Name"].Value.ToString().Trim();
                    objPurchasesOrderDetailEL.Item_id            = Convert.ToInt32(dataGridView1.Rows[i].Cells["ItemName"].Value);
                    objPurchasesOrderDetailEL.Item_Quantity      = Convert.ToDouble(dataGridView1.Rows[i].Cells["Item_Quantity"].Value);
                    objPurchasesOrderDetailEL.Item_Rate          = Convert.ToDouble(dataGridView1.Rows[i].Cells["Item_Rate"].Value);
                    objPurchasesOrderDetailEL.Purchases_Order_Id = PurchaseOrderId;
                    lstPurchasesOrderDetailEL.Add(objPurchasesOrderDetailEL);
                }

                lstPurchasesOrderDetailEL.ForEach(r => objPurchasesOrderDetailDL.Insert(objSqlTransaction, r));

                objSqlTransaction.Commit();
                Common.MessageSave();
                FillListBox();
                ControlClear();
            }
            catch
            {
                objSqlTransaction.Rollback();
                Common.MessageAlert("First enter data in correct format");
            }
        }
예제 #6
0
        void FillListBox()
        {
            try
            {
                PurchaseOrderDL objPurchasesOrderDL = new PurchaseOrderDL();

                ListPurchaseOrder.SelectedIndexChanged -= ListPurchaseOrder_SelectedIndexChanged;
                ListPurchaseOrder.DataSource            = objPurchasesOrderDL.GetPurchasesOrderByComId(companyEL.Company_id);
                ListPurchaseOrder.DisplayMember         = "Purchases_Order_No";
                ListPurchaseOrder.ValueMember           = "Purchases_Order_Id";
                ListPurchaseOrder.SelectedIndexChanged += ListPurchaseOrder_SelectedIndexChanged;
            }
            catch
            {
            }
        }
예제 #7
0
        void GridBind()
        {
            try
            {
                CompanyDL               objCompanyDL               = new CompanyDL();
                PurchaseOrderDL         _PurchaseOrderDL           = new PurchaseOrderDL();
                BillingDelivertDetailDL objBillingDelivertDetailDL = new BillingDelivertDetailDL();
                List <CompanyEL>        CompanyList = objCompanyDL.GetCompanyListByType(SelectedCompanyType);

                dataGridView1.SelectionChanged -= dataGridView1_SelectionChanged;
                dataGridView1.Click            -= dataGridView1_Click;
                dataGridView1.DataSource        = CompanyList;
                dataGridView1.Columns["Company_id"].Visible      = false;
                dataGridView1.Columns["Company_Type_Id"].Visible = false;
                //BindControl();
                dataGridView1.SelectionChanged += dataGridView1_SelectionChanged;
                dataGridView1.Click            += dataGridView1_Click;


                #region SetGrid Color for panding bill creation

                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    CompanyEL objCompanyEL = new CompanyEL();
                    objCompanyEL.Company_id = Convert.ToInt32(dataGridView1.Rows[i].Cells["company_Id"].Value);

                    List <BillingDelivertDetailEL> lstBillingDelivertDetail = objBillingDelivertDetailDL.GetUnProcessBillingDeliver(objCompanyEL);
                    lstBillingDelivertDetail = lstBillingDelivertDetail.Where(r => r.PURCHASES_ORDER_Date > Properties.Settings.Default.Create_Bill_Start_Date).ToList();

                    if (lstBillingDelivertDetail.Count > 0)
                    {
                        dataGridView1.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(172)))), ((int)(((byte)(102)))), ((int)(((byte)(202)))));
                        dataGridView1.Rows[i].DefaultCellStyle.ForeColor = System.Drawing.Color.White;
                    }
                }

                #endregion
            }
            catch
            {
            }
            ControlClear();
        }
예제 #8
0
 protected void gvPurchaseOrder_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         _currentPurchaseOrder = new PurchaseOrderDL();
         _currentPurchaseOrder.PurchaseOrderID = Convert.ToInt32(gvPurchaseOrder.DataKeys[e.RowIndex].Value);
         _currentPurchaseOrder.ScreenMode      = ScreenMode.Delete;
         TransactionResult transactionResult = _currentPurchaseOrder.Commit();
         StringBuilder     stringBuilder     = new StringBuilder();
         stringBuilder.Append(string.Concat("<script>alert(\'", transactionResult.Message.ToString(), ".\');"));
         stringBuilder.Append("</script>");
         ScriptManager.RegisterStartupScript(base.Page, typeof(string), "MyScript", stringBuilder.ToString(), false);
         if (transactionResult.Status == TransactionStatus.Success)
         {
             GetPurchaseOrderDetails();
         }
     }
     catch (Exception exception1)
     {
         ErrorLog.LogErrorMessageToDB("ManagePurchaseOrder.aspx", "", "gvPurchaseOrder_RowDeleting", exception1.Message.ToString(), new ACEConnection());
         throw;
     }
 }
        protected void btnPurchaseOrderAdd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string   dtFormat = _dateFormat;
                DateTime dTime;

                PurchaseOrderDL _currentPurchaseOrder = new PurchaseOrderDL();
                bool            bl = hfPurchaseOrderID.Value.ToString() == "0";
                _currentPurchaseOrder.AddEditOption   = !bl ? 1 : 0;
                _currentPurchaseOrder.PurchaseOrderID = Convert.ToInt32(hfPurchaseOrderID.Value.ToString());
                dTime = DateTime.ParseExact(txtPODate.Text, dtFormat, null);
                _currentPurchaseOrder.PurchaseOrderNo = txtPONO.Text;

                _currentPurchaseOrder.BuyerID           = Convert.ToInt32(ddlContact.SelectedValue);
                _currentPurchaseOrder.SendToID          = Convert.ToInt32(hfCompanyID.Value);
                _currentPurchaseOrder.PurchaseOrderDate = dTime;
                _currentPurchaseOrder.Currency          = Convert.ToString(ddlCurrency.SelectedValue);
                _currentPurchaseOrder.Shipment          = Convert.ToString(ddlShipment.SelectedValue);
                _currentPurchaseOrder.TelNo             = Convert.ToString(txtTel.Text);
                _currentPurchaseOrder.GrandTotal        = Convert.ToDecimal(lblTotalCost.Text);
                dTime = GetTodayDate(dtFormat, dTime);

                _currentPurchaseOrder.AuditDate = dTime;
                _currentPurchaseOrder.AuditID   = Convert.ToInt32(hfUserID.Value);


                _currentPurchaseOrder.ScreenMode = ScreenMode.Add;
                TransactionResult transactionResult = _currentPurchaseOrder.Commit();

                bl = transactionResult.Status != TransactionStatus.Success;
                if (!bl)
                {
                    hfPurchaseOrderID.Value = _currentPurchaseOrder.PurchaseOrderID.ToString();

                    trEnablePurchaseWorkOrder.Visible = true;

                    //OrderAcceptanceParticularsListDL listDL;

                    //foreach (GridViewRow innerRow in gvPurchaseWorkOrder.Rows)
                    //{

                    //    listDL = new OrderAcceptanceParticularsListDL();

                    //    if (innerRow.Cells[3].Text.ToString() == "")
                    //        innerRow.Cells[3].Text = "0";

                    //    bool b2 = innerRow.Cells[3].Text.ToString() == "0";
                    //    listDL.AddEditOption = !b2 ? 1 : 0;

                    //    listDL.OrderAcceptanceParticularsListID = Convert.ToInt32(innerRow.Cells[3].Text.ToString());
                    //    listDL.PurchaseOrderID = Convert.ToInt32(hfPurchaseOrderID.Value.ToString());
                    //    listDL.ParticularsID = Convert.ToInt32(innerRow.Cells[1].Text.ToString());

                    //    RadioButton rbYes = (RadioButton)innerRow.Cells[4].FindControl("rbCheckYes");
                    //    RadioButton rbNo = (RadioButton)innerRow.Cells[4].FindControl("rbCheckNo");
                    //    TextBox txtRemarks = (TextBox)innerRow.Cells[5].FindControl("txtRemarks");
                    //    listDL.StatusYes = rbYes.Checked;
                    //    listDL.StatusNo = rbNo.Checked;
                    //    listDL.Remarks = txtRemarks.Text;

                    //    listDL.ScreenMode = ScreenMode.Add;
                    //    listDL.Commit();
                    //}



                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(string.Concat("<script>alert(\'", transactionResult.Message.ToString(), ".\');"));
                    stringBuilder.Append("</script>");
                    ScriptManager.RegisterStartupScript(base.Page, typeof(string), "MyScript", stringBuilder.ToString(), false);
                }
                else
                {
                    //txtAvailablecount.Text = "0";
                    //lblPurchaseOrderID.Text = "0";
                }
            }
            catch (Exception exception1)
            {
                ErrorLog.LogErrorMessageToDB("ManagePurchaseOrder.aspx", "", "btnPurchaseOrderAdd_Click", exception1.Message.ToString(), new ACEConnection());
                throw;
            }
        }
예제 #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //if ((string.IsNullOrEmpty( textPuchasesOrderNo.Text.Trim())))
            //{
            //    Common.MessageAlert("First enter Purchases Order No");
            //    return;
            //}
            decimal result;

            if (string.IsNullOrEmpty(textTax.Text.Trim()) || !decimal.TryParse(textTax.Text, out result))
            {
                Common.MessageAlert("First enter Tax Percentage");
                return;
            }
            if (dataGridView1.Rows.Count - 1 <= 0)
            {
                Common.MessageAlert("First Enter Item Detail");
                return;
            }

            SQLHelper      objSQLHelper      = new SQLHelper();
            SqlTransaction objSqlTransaction = objSQLHelper.BeginTrans();

            try
            {
                PurchaseOrderEL               objPurchaseOrderEL  = new PurchaseOrderEL();
                PurchaseOrderDL               objPurchasesOrderDL = new PurchaseOrderDL();
                PurchasesOrderDetailEL        objPurchasesOrderDetailEL;
                List <PurchasesOrderDetailEL> lstPurchasesOrderDetailEL = new List <PurchasesOrderDetailEL>();
                PurchasesOrderDetailDL        objPurchasesOrderDetailDL = new PurchasesOrderDetailDL();

                objPurchaseOrderEL.Company_id     = SelectedCompany.Company_id;
                objPurchaseOrderEL.Date           = dateTimePickerPurchasesOrderDate.Value;
                objPurchaseOrderEL.Tax_Percentage = Convert.ToDecimal(textTax.Text);

                if (string.IsNullOrEmpty(txtOtherAmount.Text.Trim()))
                {
                    objPurchaseOrderEL.Other_Amount = 0;
                }
                else
                {
                    objPurchaseOrderEL.Other_Amount = Convert.ToDecimal(txtOtherAmount.Text);
                }



                objPurchaseOrderEL.Requisitioner      = txtRequisitioner.Text;
                objPurchaseOrderEL.Credit_Term        = txtCreditTerm.Text;
                objPurchaseOrderEL.Shipping_Term      = txtShippingTerm.Text;
                objPurchaseOrderEL.Comments           = txtComments.Text;
                objPurchaseOrderEL.Purchases_Order_No = textPuchasesOrderNo.Text.Trim();
                int PurchaseOrderId = objPurchasesOrderDL.Insert(objSqlTransaction, objPurchaseOrderEL);


                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    objPurchasesOrderDetailEL = new PurchasesOrderDetailEL();
                    //objPurchasesOrderDetailEL.Item_Name = dataGridView1.Rows[i].Cells["Item_Name"].Value.ToString().Trim();
                    objPurchasesOrderDetailEL.Item_id            = Convert.ToInt32(dataGridView1.Rows[i].Cells["ItemName"].Value);
                    objPurchasesOrderDetailEL.Item_Quantity      = Convert.ToDouble(dataGridView1.Rows[i].Cells["Item_Quantity"].Value);
                    objPurchasesOrderDetailEL.Item_Rate          = Convert.ToDouble(dataGridView1.Rows[i].Cells["Item_Rate"].Value);
                    objPurchasesOrderDetailEL.Item_Unit          = dataGridView1.Rows[i].Cells["Item_Unit"].Value.ToString();
                    objPurchasesOrderDetailEL.Purchases_Order_Id = PurchaseOrderId;
                    lstPurchasesOrderDetailEL.Add(objPurchasesOrderDetailEL);
                }

                lstPurchasesOrderDetailEL.ForEach(r => objPurchasesOrderDetailDL.Insert(objSqlTransaction, r));

                objSqlTransaction.Commit();
                Common.MessageSave();
                FillListBox();
                ControlClear();
            }
            catch
            {
                objSqlTransaction.Rollback();
                Common.MessageAlert("First enter data in correct format");
            }
        }