コード例 #1
0
ファイル: Update.aspx.cs プロジェクト: atiburrahman09/Signbd
        protected void updateButton_Click(object sender, EventArgs e)
        {
            ProductBLL product = new ProductBLL();

            try
            {
                if (productIdForUpdateHiddenField.Value.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Product not found to update.";
                }
                //else if (barcodeTextBox.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Barcode Name field is required.";
                //}
                else if (productNameOnlyTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Name field is required.";
                }
                else if (productVolumeTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Volume field is required.";
                }
                //else if (volumeQuantityTextBox.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Volume Quantity field is required.";
                //}
                else if (unitTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Unit field is required.";
                }
                //else if (vendorDropDownList.SelectedValue == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Vendor field is required.";
                //}
                else if (productGroupDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Group field is required.";
                }
                else
                {
                    product.ProductId = productIdForUpdateHiddenField.Value.Trim();
                    product.ProductNameOnly = productNameOnlyTextBox.Text.Trim();
                    product.Barcode = "";
                    product.ProductGroupId = productGroupDropDownList.SelectedValue.Trim();
                    product.SecondaryUnit = "";//secondaryUnitTextBox.Text.Trim();
                    product.ProductType = productTypeDropDownList.SelectedValue.Trim();
                    product.SubProduct = subProductDropDownList.SelectedValue.Trim();
                    product.ProductVolume = productVolumeTextBox.Text.Trim();
                    product.VolumeQuantity = decimal.Parse(volumeQuantityTextBox.Text.Trim());
                    product.Unit = unitTextBox.Text.Trim();
                    product.additinalInfo = txtBxAddition.Text;
                    if (productTypeDropDownList.SelectedValue == "Yes")
                    {
                        product.VendorId = vendorDropDownList.SelectedValue;
                    }
                    else
                    {
                        product.VendorId = "";
                    }
                    product.ProductName = product.ProductNameOnly.Trim() + "[" + " (" + product.additinalInfo.Trim() + ") " + product.ProductVolume.Trim() + "]";
                    product.salescenter = ""; //salescenterDropDownList.SelectedValue;
                    product.WareHouseId = warehouseDropDownList.SelectedValue;
                    product.productImageName = "";
                    product.productDesc = txtProductDesc.Text;

                    string updateCondition = "";

                    //if (barcodeForUpdateHiddenField.Value != product.Barcode.Trim())
                    //{
                    //    if (!product.CheckDuplicateProductByBarcode(product.Barcode.Trim()))
                    //    {
                    //        updateCondition += "Brc";
                    //    }
                    //    else
                    //    {
                    //        string message1 = "This Barcode <span class='actionTopic'>already exist</span>, try another one.";
                    //        MyAlertBox("WarningAlert(\"" + "Data Duplicate" + "\", \"" + message1 + "\");");
                    //        return;
                    //    }
                    //}

                    if (productNameForUpdateHiddenField.Value != product.ProductName.Trim())
                    {
                        if (!product.CheckDuplicateProductByName(product.ProductName.Trim(), product.WareHouseId, product.salescenter))
                        {
                            updateCondition += "Prdn";
                        }
                        else
                        {
                            string message2 = "This Product Name <span class='actionTopic'>already exist</span>, try another one.";
                            MyAlertBox("WarningAlert(\"" + "Data Duplicate" + "\", \"" + message2 + "\");");
                            return;
                        }
                    }
                    //string iamgeName = saveProductImage(product.Barcode.Trim());
                    //if (iamgeName == "")
                    //{
                    //    product.productImageName = ImageNameHiddenField.Value;
                    //}
                    //else
                    //{
                    //    product.productImageName = iamgeName;
                    //}
                    List<string> mainProductList = new List<string>();

                    for (int i = 0; i < mainProductListListBox.Items.Count; i++)
                    {
                        mainProductList.Add(mainProductListListBox.Items[i].Value);
                    }
                    product.UpdateProduct(mainProductList, updateCondition);
                    productNameForUpdateHiddenField.Value = "";
                    productIdForUpdateHiddenField.Value = "";
                    barcodeForUpdateHiddenField.Value = "";

                    string message = "Product <span class='actionTopic'>Updated</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Product/List.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                product = null;
            }
        }
コード例 #2
0
ファイル: Create.aspx.cs プロジェクト: atiburrahman09/Signbd
        protected void saveButton_Click(object sender, EventArgs e)
        {
            ProductBLL product = new ProductBLL();

            try
            {
                //if (barcodeTextBox.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Barcode Name field is required.";
                //}
                //else
                if (productNameOnlyTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Name field is required.";
                }
                else if (productVolumeTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Volume field is required.";
                }
                //else if (volumeQuantityTextBox.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Volume Quantity field is required.";
                //}
                else if (unitTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Unit field is required.";
                }
                else if (productRateTextBox.Text == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Rate field is required.";
                }
                //else if (vatPercentageTextBox.Text == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "VAT field is required.";
                //}
                else if (productGroupDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Group field is required.";
                }
                //else if (vendorDropDownList.SelectedValue == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Product Vendor field is required.";
                //}
                else
                {
                    int isaddanother = 1;

                    Button btn = (Button)sender;

                    if (btn.Text == "Save")
                    {
                        isaddanother = 0;
                    }

                    product.ProductNameOnly = productNameOnlyTextBox.Text.Trim();
                    product.Barcode = ""; //barcodeTextBox.Text.Trim();
                    product.ProductGroupId = productGroupDropDownList.SelectedValue.Trim();
                    product.SecondaryUnit = "";//secondaryUnitTextBox.Text.Trim();
                    product.ProductType = productTypeDropDownList.SelectedValue.Trim();
                    product.SubProduct = subProductDropDownList.SelectedValue.Trim();
                    product.ProductVolume = productVolumeTextBox.Text.Trim();
                    product.additinalInfo = txtBxAddition.Text.Trim();
                    product.VolumeQuantity = decimal.Parse(volumeQuantityTextBox.Text.Trim());
                    product.Unit = unitTextBox.Text.Trim();
                    product.ProductRate = decimal.Parse(productRateTextBox.Text.Trim());
                    product.ProductName = product.ProductNameOnly.Trim() + " [" + " (" + product.additinalInfo.Trim() + ") " + product.ProductVolume.Trim() + "]";
                    product.VendorId = vendorDropDownList.SelectedValue;
                    product.VATPercentage = float.Parse(vatPercentageTextBox.Text.Trim());
                    product.WareHouseId = warehouseDropDownList.SelectedValue;
                    product.salescenter = "";

                    product.productDesc = txtProductDesc.Text.Trim();

                    //if (!product.CheckDuplicateProductByBarcode(product.Barcode.Trim()))
                    //{
                    if (!product.CheckDuplicateProductByName(product.ProductName.Trim(), product.WareHouseId, product.salescenter))
                    {
                        List<string> mainProductList = new List<string>();

                        if (productTypeDropDownList.SelectedValue == "No")
                        {
                            for (int i = 0; i < mainProductListListBox.Items.Count; i++)
                            {
                                mainProductList.Add(mainProductListListBox.Items[i].Value);
                            }
                        }
                        product.productImageName = "";//saveProductImage(product.Barcode);
                        DataTable dt = product.SaveProduct(mainProductList);

                        if (dt.Rows.Count > 0)
                        {
                            if (isaddanother == 0)
                            {
                                string message =
                                    "Product <span class='actionTopic'>Created</span> Successfully with Product ID: <span class='actionTopic'>" +
                                    dt.Rows[0][0].ToString() + "</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Product/List.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                            }
                            else
                            {
                                string message =
                                   "Product <span class='actionTopic'>Created</span> Successfully with Product ID: <span class='actionTopic'>" +
                                   dt.Rows[0][0].ToString() + "</span>.";
                                MyAlertBox(
                                    "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Product/Create.aspx\"; }; SuccessAlert(\"" +
                                    "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                            }
                        }
                        else
                        {
                            string message = "<span class='actionTopic'>Failed</span> to Create Product.";
                            MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");");
                        }
                    }
                    else
                    {
                        string message = "This Product Name <span class='actionTopic'>already exist</span>, try another one.";
                        MyAlertBox("WarningAlert(\"" + "Data Duplicate" + "\", \"" + message + "\");");
                    }
                    //}
                    //else
                    //{
                    //    string message = "This Barcode <span class='actionTopic'>already exist</span>, try another one.";
                    //    MyAlertBox("WarningAlert(\"" + "Data Duplicate" + "\", \"" + message + "\");");
                    //}
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                product = null;
            }
        }
コード例 #3
0
        protected void updateButton_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;
            List<ProductPriceBLL> productPrices = new List<ProductPriceBLL>();
            ProductPriceBLL productPrice;
            decimal newRate = 0;
            decimal newUnitPrice = 0;
            float newVAT = 0;
            CheckBox selectCheckBox;
            TextBox newPriceTextBox;
            TextBox newUnitPriceTextBox;
            TextBox newVATPercentageTextBox;
            int i = 0;

            try
            {
                for (i = 0; i < productPriceListGridView.Rows.Count; i++)
                {
                    selectCheckBox = (CheckBox)productPriceListGridView.Rows[i].Cells[7].FindControl("selectCheckBox");
                    newUnitPriceTextBox = (TextBox)productPriceListGridView.Rows[i].Cells[4].FindControl("lastUnitTextBox");
                    newPriceTextBox = (TextBox)productPriceListGridView.Rows[i].Cells[5].FindControl("newPriceTextBox");
                    newVATPercentageTextBox = (TextBox)productPriceListGridView.Rows[i].Cells[6].FindControl("newVATPercentageTextBox");

                    if (selectCheckBox.Checked && string.IsNullOrEmpty(newPriceTextBox.Text.Trim()))
                    {
                        msg = "Product ID [" + productPriceListGridView.Rows[i].Cells[0].Text.ToString() + "] has no price to update new price.";
                        msgbox.Visible = true; msgTitleLabel.Text = "Warning!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else if (selectCheckBox.Checked && string.IsNullOrEmpty(newVATPercentageTextBox.Text.Trim()))
                    {
                        msg = "Product ID [" + productPriceListGridView.Rows[i].Cells[0].Text.ToString() + "] has no Discount(%) to update Discount VAT(%).";
                        msgbox.Visible = true; msgTitleLabel.Text = "Warning!!!"; msgDetailLabel.Text = msg;
                        return;
                    }
                    else if (selectCheckBox.Checked)
                    {
                        newUnitPrice = decimal.Parse(newUnitPriceTextBox.Text.Trim());
                        newRate = decimal.Parse(newPriceTextBox.Text.Trim());
                        newVAT = float.Parse(newVATPercentageTextBox.Text.Trim());

                        productPrice = new ProductPriceBLL();
                        productPrice.ProductId = productPriceListGridView.Rows[i].Cells[0].Text.ToString();
                        productPrice.RatePerUnit = newRate;
                        productPrice.VATPercentage = newVAT;
                        productPrice.NewUnitPrice = newUnitPrice;

                        productPrices.Add(productPrice);
                    }
                }

                if (productPrices.Count > 0)
                {
                    productPrice = new ProductPriceBLL();
                    productPrice.UpdateProductPriceList(productPrices);

                    string message = "Product Price(s) & Discount(%) <span class='actionTopic'>Updated</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { $('#allProductListButton').click(); }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
                else if (string.IsNullOrEmpty(msg))
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Warning!!!"; msgDetailLabel.Text = "No Product is selected to update product price.";
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "Input string was not in a correct format.")
                {
                    msg = "Product ID [" + productPriceListGridView.Rows[i].Cells[0].Text.ToString() + "] has no valid price or VAT(%) to update new price.";
                    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = msg;
                }
                else
                {
                    string message = ex.Message;
                    if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                    MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
                }
            }
            finally
            {
                productPrice = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
コード例 #4
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            VendorBLL vendor = new VendorBLL();
            List<string> vendors = new List<string>();

            try
            {
                if (productVendorListListBox.Items.Count > 0)
                {
                    for (int i = 0; i < productVendorListListBox.Items.Count; i++)
                    {
                        vendors.Add(productVendorListListBox.Items[i].Value.Trim());
                    }

                    vendor.SaveProductVendorsByProductId(productIdLabel.Text.Trim(), vendors);

                    string message = "Product's Vendor List <span class='actionTopic'>Saved</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/Product/ManageProductVendor.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
                else
                {
                    string message = "No Vendor is added for this product, must be added one or more vendor(s).";
                    MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                vendor = null;
                vendors = null;
            }
        }