private List <PurchaseOrderDetailProvider> purchaseOrderDetailEntityList()
        {
            List <PurchaseOrderDetailProvider> purchaseLedgerDetailsProviderList = new List <PurchaseOrderDetailProvider>();

            foreach (GridViewRow row in gvPurchaseOrder.Rows)
            {
                PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();

                HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID");
                TextBox     txtQuantity    = (TextBox)row.FindControl("txtQuantity");
                TextBox     txtRemarks     = (TextBox)row.FindControl("txtRemarks");
                ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE");

                Label   lblProductName = (Label)row.FindControl("lblProduct");
                TextBox txtUnit        = (TextBox)row.FindControl("txtUnit");

                TextBox txtRate  = (TextBox)row.FindControl("txtRate");
                TextBox txtValue = (TextBox)row.FindControl("txtValue");

                obj.ProductID = hfRowProductID.Value.Toint();
                obj.Quantity  = txtQuantity.Text.ToDecimal();
                obj.Rate      = txtRate.Text.ToDecimal();
                obj.Value     = txtValue.Text.ToDecimal();
                obj.Unit      = txtUnit.Text.ToString();

                if (obj.Quantity <= 0 || obj.Rate <= 0)
                {
                    throw new Exception("Quantity and rate can't be zero");
                }

                purchaseLedgerDetailsProviderList.Add(obj);
            }
            return(purchaseLedgerDetailsProviderList);
        }
        private void RowsIn_gvPurchaseOrder()
        {
            List <PurchaseOrderDetailProvider> purchaseLedgerDetailsProviderList = new List <PurchaseOrderDetailProvider>();

            foreach (GridViewRow row in gvPurchaseOrder.Rows)
            {
                PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();
                HiddenField hfRowProductID      = (HiddenField)row.FindControl("hfProductID");
                Label       lblProductName      = (Label)row.FindControl("lblProduct");
                TextBox     txtQuantity         = (TextBox)row.FindControl("txtQuantity");
                TextBox     txtRate             = (TextBox)row.FindControl("txtRate");
                TextBox     txtUnit             = (TextBox)row.FindControl("txtUnit");

                obj.ProductID   = hfRowProductID.Value.Toint();
                obj.ProductName = lblProductName.Text.ToString();
                obj.Quantity    = txtQuantity.Text.ToDecimal();
                obj.Rate        = txtRate.Text.ToDecimal();
                obj.Unit        = txtUnit.Text;
                obj.Value       = txtQuantity.Text.ToDecimal() * txtRate.Text.ToDecimal();

                purchaseLedgerDetailsProviderList.Add(obj);
                txtQuantity.Focus();
            }
            gvPurchaseOrder.DataSource = purchaseLedgerDetailsProviderList;
            gvPurchaseOrder.DataBind();
        }
示例#3
0
        public bool Delete(PurchaseOrderDetailProvider provider)
        {
            bool IsDelete = false;

            try
            {
                SqlCommand command = new SqlCommand();
                this.ConnectionOpen();
                command.Connection = Connection;
                this.BeginTransaction(true);
                command.Transaction = this.Transaction;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = StoredProcedureNames.RequisitionDetailSet;
                command.Parameters.Add("@ID", SqlDbType.Int).Value     = provider.ID;
                command.Parameters.Add("@Option", SqlDbType.Int).Value = DBConstants.DataModificationOption.Delete;
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsDelete = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsDelete);
        }
示例#4
0
        public bool Update(PurchaseOrderDetailProvider provider)
        {
            bool IsUpdate = false;

            try
            {
                SqlCommand command = null;
                command = ProcedureFunction(provider);
                command.Parameters.Add("@ID", SqlDbType.Int).Value           = provider.ID;
                command.Parameters.Add("@UpdateUserID", SqlDbType.Int).Value = provider.UpdateUserID;
                command.Parameters.Add("@Option", SqlDbType.Int).Value       = DBConstants.DataModificationOption.Update;
                command.ExecuteNonQuery();
                this.CommitTransaction();
                this.ConnectionClosed();
                IsUpdate = true;
            }
            catch (Exception exp)
            {
                this.RollbackTransaction();
                throw new Exception(exp.Message);
            }
            finally
            {
                this.ConnectionClosed();
            }
            return(IsUpdate);
        }
示例#5
0
        private SqlCommand ProcedureFunction(PurchaseOrderDetailProvider provider)
        {
            SqlCommand command = new SqlCommand();

            this.ConnectionOpen();
            command.Connection = Connection;
            this.BeginTransaction(true);
            command.Transaction = this.Transaction;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = StoredProcedureNames.RequisitionDetailSet;
            return(command);
        }
        protected void btnAddRow_Click(object sender, EventArgs e)
        {
            this.AlertNone(lblMsg);
            AjaxControlToolkit.ComboBox ddlProductValidation = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct");
            if (ddlProductValidation.SelectedValue == "")
            {
                MessageHelper.ShowAlertMessage("Select Product!");
                return;
            }
            string productName = ddlProductValidation.SelectedItem.Text;
            int    productID   = ddlProductValidation.SelectedValue.Toint();

            List <PurchaseOrderDetailProvider> providerList = new List <PurchaseOrderDetailProvider>();

            PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();

            providerList.Add(obj);
        }
        protected void btnDeleteSelectedRowLSE_Click(object sender, EventArgs e)
        {
            ImageButton btnDelete      = sender as ImageButton;
            GridViewRow selectedRow    = (GridViewRow)btnDelete.NamingContainer;
            HiddenField hfDeleteProdID = (HiddenField)selectedRow.FindControl("hfProductID");
            List <PurchaseOrderDetailProvider> purchaseLedgerDetailsProviderList = new List <PurchaseOrderDetailProvider>();

            foreach (GridViewRow row in gvPurchaseOrder.Rows)
            {
                PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();

                HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID");
                Label       lblProductName = (Label)row.FindControl("lblProduct");
                TextBox     txtValue       = (TextBox)row.FindControl("txtValue");
                ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE");

                TextBox txtQuantity = (TextBox)row.FindControl("txtQuantity");
                TextBox txtRate     = (TextBox)row.FindControl("txtRate");
                TextBox txtUnit     = (TextBox)row.FindControl("txtUnit");

                if (hfRowProductID.Value != hfDeleteProdID.Value)
                {
                    obj.ProductID   = hfRowProductID.Value.Toint();
                    obj.ProductName = lblProductName.Text.ToString();
                    obj.Quantity    = txtQuantity.Text.ToDecimal();

                    obj.Value = txtValue.Text.ToDecimal();
                    obj.Rate  = txtRate.Text.ToDecimal();
                    obj.Unit  = txtUnit.Text.ToString();

                    purchaseLedgerDetailsProviderList.Add(obj);
                }
            }
            gvPurchaseOrder.DataSource = purchaseLedgerDetailsProviderList;
            gvPurchaseOrder.DataBind();
            if (gvPurchaseOrder.Rows.Count == 0)
            {
                ddlRequistionRef.Enabled = true;
            }
        }
示例#8
0
        private void RowsIn_gvPurchaseOrder()
        {
            List <PurchaseOrderDetailProvider> deliveryDetailsProviderList = new List <PurchaseOrderDetailProvider>();

            foreach (GridViewRow row in gvDeliveryChallan.Rows)
            {
                PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();
                HiddenField hfRowProductID      = (HiddenField)row.FindControl("hfProductID");
                Label       lblProductName      = (Label)row.FindControl("lblProduct");
                TextBox     txtProvidedQuantity = (TextBox)row.FindControl("txtProvidedQuantity");
                Label       lblTotalAmount      = (Label)row.FindControl("lblTotalAmount");
                ImageButton btnAddOrDelete      = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE");

                obj.ProductID   = hfRowProductID.Value.Toint();
                obj.ProductName = lblProductName.Text.ToString();
                obj.Quantity    = txtProvidedQuantity.Text.ToDecimal();

                deliveryDetailsProviderList.Add(obj);
            }
            gvDeliveryChallan.DataSource = deliveryDetailsProviderList;
            gvDeliveryChallan.DataBind();
        }
        protected void btnAdd_OnClick(object sender, EventArgs e)
        {
            this.AlertNone(lblMsg);

            ProductProvider productProvider = new ProductProvider();

            AjaxControlToolkit.ComboBox ddlProductValidation = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct");

            string requisitionAndDate = ddlRequistionRef.SelectedItem.Text;

            string[] splitValue       = requisitionAndDate.Split(' ');
            string   requisitionRefNo = splitValue[0];

            bool isExist = productProvider.GetMeasurementUnit(ddlProductValidation.SelectedValue.Toint(), requisitionRefNo);

            if (isExist == false)
            {
                MessageHelper.ShowAlertMessage("This product is not listed in the requistion");

                return;
            }
            if (ddlProductValidation.SelectedValue == "")
            {
                MessageHelper.ShowAlertMessage("Select Product!");
                lblMsg.Focus();
                return;
            }

            List <PurchaseOrderDetailProvider> purchaseLedgerDetailsProviderList = new List <PurchaseOrderDetailProvider>();

            foreach (GridViewRow row in gvPurchaseOrder.Rows)
            {
                PurchaseOrderDetailProvider obj = new PurchaseOrderDetailProvider();

                HiddenField hfRowProductID = (HiddenField)row.FindControl("hfProductID");
                Label       lblProductName = (Label)row.FindControl("lblProduct");
                TextBox     txtRate        = (TextBox)row.FindControl("txtRate");

                TextBox     txtValue       = (TextBox)row.FindControl("txtValue");
                TextBox     txtQuantity    = (TextBox)row.FindControl("txtQuantity");
                TextBox     txtUnit        = (TextBox)row.FindControl("txtUnit");
                Label       lblTotalAmount = (Label)row.FindControl("lblTotalAmount");
                ImageButton btnAddOrDelete = (ImageButton)row.FindControl("btnDeleteSelectedRowLSE");

                if (hfRowProductID.Value == ddlProductValidation.SelectedValue)
                {
                    MessageHelper.ShowAlertMessage("This product already added!");
                    return;
                }
                if (txtQuantity.Text.ToDecimal() <= 0)
                {
                    MessageHelper.ShowAlertMessage("Enter Quantity!");
                    return;
                }
                obj.ProductID   = hfRowProductID.Value.Toint();
                obj.ProductName = lblProductName.Text.ToString();
                obj.Quantity    = txtQuantity.Text.ToDecimal();
                obj.Rate        = txtRate.Text.ToDecimal();
                obj.Value       = txtValue.Text.ToDecimal();
                obj.Unit        = txtUnit.Text;
                purchaseLedgerDetailsProviderList.Add(obj);
            }

            AjaxControlToolkit.ComboBox ddlProduct = (AjaxControlToolkit.ComboBox)UC_ProductSearch1.FindControl("ddlProduct");
            string productName = ddlProduct.SelectedItem.Text;
            int    productID   = ddlProduct.SelectedValue.Toint();

            PurchaseOrderDetailProvider obj2 = new PurchaseOrderDetailProvider();

            obj2.ProductID   = productID;
            obj2.ProductName = productName;
            obj2.Rate        = obj2.GetLastUnitPrice(obj2.ProductID);
            obj2.Unit        = productProvider.GetMeasurementUnit(obj2.ProductID);
            purchaseLedgerDetailsProviderList.Add(obj2);

            if (!divGridForPO.Visible)
            {
                divGridForPO.Visible = true;
            }
            gvPurchaseOrder.DataSource = purchaseLedgerDetailsProviderList;
            gvPurchaseOrder.DataBind();
            ddlProductDivision.Enabled = false;
            RadioButtonList rbProductType = (RadioButtonList)UC_ProductSearch1.FindControl("rbProductType");

            rbProductType.Enabled = false;
        }