Esempio n. 1
0
    private void InsertData(GridViewRow gRow)
    {
        TextBox txtBarcode = (TextBox)gRow.Cells[1].FindControl("txtNewBarcode");
        TextBox txtAbbname = (TextBox)gRow.Cells[2].FindControl("txtNewAbbname");
        TextBox txtMultiply = (TextBox)gRow.Cells[3].FindControl("txtNewMultiply");
        DropDownList cmbUnit = (DropDownList)gRow.Cells[5].FindControl("cmbNewUnit");
        TextBox txtCost = (TextBox)gRow.Cells[6].FindControl("txtNewCost");
        TextBox txtPrice = (TextBox)gRow.Cells[7].FindControl("txtNewPrice");
        CheckBox chkIsVAT = (CheckBox)gRow.Cells[8].FindControl("chkNewIsVAT");
        CheckBox chkIsDiscount = (CheckBox)gRow.Cells[9].FindControl("chkNewIsDiscount");
        TextBox txtPackSize = (TextBox)gRow.Cells[10].FindControl("txtNewPackSize");
        DropDownList cmbUnitPack = (DropDownList)gRow.Cells[11].FindControl("cmbNewUnitPack");

        ProductBarcodeData data = new ProductBarcodeData();
        data.UNITMASTER = FlowObj.GetUnitName(this.txtMasterUnit.Text);
        //data.UNITPACK = FlowObj.GetUnitName(this.txtPackSizeUint.Text);
        data.BARCODE = txtBarcode.Text.Trim();
        data.ABBNAME = txtAbbname.Text.Trim();
        data.MULTIPLY = Convert.ToDouble(txtMultiply.Text == "" ? "0" : txtMultiply.Text);
        data.UNIT = Convert.ToDouble(cmbUnit.SelectedValue);
        data.UNITPACK = Convert.ToDouble(cmbUnitPack.SelectedValue);
        data.COST = Convert.ToDouble(txtCost.Text == "" ? "0" : txtCost.Text);
        data.PRICE = Convert.ToDouble(txtPrice.Text == "" ? "0" : txtPrice.Text);
        data.ISVAT = (chkIsVAT.Checked ? "1" : "0");
        data.ISDISCOUNT = (chkIsDiscount.Checked ? "1" : "0");
        data.PACKSIZE = Convert.ToDouble(txtPackSize.Text == "" ? "0" : txtPackSize.Text);

        if (ItemObj.InsertItem(data))
        {
            this.grvItem.DataBind();
        }
        else
            Appz.ClientAlert(this, ItemObj.ErrorMessage);
    }
Esempio n. 2
0
    public bool UpdateItem(decimal LOID, string BARCODE, string ABBNAME, decimal MULTIPLY, string UNITMASTER, decimal UNIT, decimal COST, decimal PRICE, string ISVAT, string ISDISCOUNT, decimal PACKSIZE, decimal UNITPACK, decimal ACTIVE)
    {
        ProductBarcodeData data = new ProductBarcodeData();
        data.LOID = Convert.ToDouble(LOID);
        data.BARCODE = BARCODE;
        data.UNIT = Convert.ToDouble(UNIT);
        data.COST = Convert.ToDouble(COST);
        data.PRICE = Convert.ToDouble(PRICE);
        data.MULTIPLY = Convert.ToDouble(MULTIPLY);
        data.ACTIVE = Convert.ToDouble(ACTIVE);
        data.ABBNAME = ABBNAME;

        bool ret = true;
        ret = VerifyData(data);
        if (ret)
        {
            DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
            if (dt != null)
            {
                DataRow[] dRows = dt.Select("LOID = " + data.LOID.ToString());
                DataRow dRow = dRows[0];
                dRow["BARCODE"] = data.BARCODE;
                dRow["ABBNAME"] = data.ABBNAME;
                dRow["MULTIPLY"] = data.MULTIPLY;
                dRow["UNITMASTER"] = UNITMASTER;
                dRow["UNIT"] = data.UNIT;
                dRow["COST"] = data.COST;
                dRow["PRICE"] = data.PRICE;
                dRow["ISVAT"] = ISVAT;
                dRow["ISDISCOUNT"] = ISDISCOUNT;
                dRow["ACTIVE"] = data.ACTIVE;
                dRow["PACKSIZE"] = Convert.ToDouble(PACKSIZE);
                dRow["UNITPACK"] = UNITPACK;

                ReOrder(dt);
                System.Web.HttpContext.Current.Session[sessionName] = dt;
            }
        }
        else throw new ApplicationException(_error);
        return ret;
    }
Esempio n. 3
0
    protected void grvItem_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        TextBox txtBarcode = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[1].FindControl("txtBarcode");
        TextBox txtAbbname = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[2].FindControl("txtAbbname");
        TextBox txtMultiply = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[3].FindControl("txtMultiply");
        DropDownList cmbUnit = (DropDownList)this.grvItem.Rows[e.RowIndex].Cells[5].FindControl("cmbUnit");
        TextBox txtCost = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[6].FindControl("txtCost");
        TextBox txtPrice = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtPrice");
        TextBox txtStdPrice = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[8].FindControl("txtStdPrice");
        TextBox txtPackSize = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[9].FindControl("txtPackSize");
        DropDownList cmbUnitPack = (DropDownList)this.grvItem.Rows[e.RowIndex].Cells[10].FindControl("cmbUnitPack");
        CheckBox chkIsActive = (CheckBox)this.grvItem.Rows[e.RowIndex].Cells[11].FindControl("chkIsActive");

        ProductBarcodeData data = new ProductBarcodeData();
        data.UNITMASTER = FlowObj.GetUnitName(this.txtMasterUnit.Text);
        data.UNITPACK = Convert.ToDouble(cmbUnitPack.SelectedValue);
        data.BARCODE = txtBarcode.Text.Trim();
        data.ABBNAME = txtAbbname.Text.Trim();
        data.MULTIPLY = Convert.ToDouble(txtMultiply.Text == "" ? "0" : txtMultiply.Text);
        data.UNIT = Convert.ToDouble(cmbUnit.SelectedValue);
        //data.UNITPACK = Convert.ToDouble(FlowObj.GetUnitPackName(cmbUnitPack.SelectedValue));
        data.COST = Convert.ToDouble(txtCost.Text == "" ? "0" : txtCost.Text);
        data.PRICE = Convert.ToDouble(txtPrice.Text == "" ? "0" : txtPrice.Text);
        data.STDPRICE = Convert.ToDouble(txtStdPrice.Text == "" ? "0" : txtStdPrice.Text);
        data.PACKSIZE = Convert.ToDouble(txtPackSize.Text == "" ? "0" : txtPackSize.Text);
        if (chkIsActive.Checked == true)
        {
            data.ACTIVE = 1;
        }
        else
        {
            data.ACTIVE = 0;
        }

        e.NewValues["UNITMASTER"] = data.UNITMASTER;
        e.NewValues["UNITPACK"] = data.UNITPACK;
        e.NewValues["BARCODE"] = data.BARCODE;
        e.NewValues["ABBNAME"] = data.ABBNAME;
        e.NewValues["MULTIPLY"] = data.MULTIPLY.ToString();
        e.NewValues["UNIT"] = data.UNIT.ToString();
        e.NewValues["COST"] = data.COST.ToString();
        e.NewValues["PRICE"] = data.PRICE.ToString();
        e.NewValues["STDPRICE"] = data.STDPRICE.ToString();
        e.NewValues["PACKSIZE"] = data.PACKSIZE;
        e.NewValues["ACTIVE"] = data.ACTIVE;

    }
Esempio n. 4
0
 public ArrayList GetItemList()
 {
     DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
     ArrayList arr = new ArrayList();
     if (dt != null)
     {
         foreach (DataRow dRow in dt.Rows)
         {
             ProductBarcodeData data = new ProductBarcodeData();
             data.LOID = Convert.ToDouble(dRow["LOID"]);
             data.BARCODE = dRow["BARCODE"].ToString();
             data.ABBNAME = dRow["ABBNAME"].ToString();
             data.MULTIPLY = Convert.ToDouble(dRow["MULTIPLY"]);
             data.ACTIVE = Convert.ToDouble(dRow["ACTIVE"]);
             data.UNIT = Convert.ToDouble(dRow["UNIT"]);
             data.UNITPACK = Convert.ToDouble(dRow["UNITPACK"]);
             data.COST = Convert.ToDouble(dRow["COST"]);
             data.PRICE = Convert.ToDouble(dRow["PRICE"]);
             data.STDPRICE = Convert.ToDouble(dRow["STDPRICE"]);
             if (!Convert.IsDBNull(dRow["PACKSIZE"])) data.PACKSIZE = Convert.ToDouble(dRow["PACKSIZE"]);
             arr.Add(data);
         }
     }
     return arr;
 }
Esempio n. 5
0
    public bool InsertItem(ProductBarcodeData data)
    {
        bool ret = true;
        ret = VerifyData(data);
        if (ret)
        {
            DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
            if (dt != null)
            {
                ReOrder(dt);
                DataRow dRow = dt.NewRow();
                dRow["LOID"] = Convert.ToDouble(dt.Rows.Count) + 1;
                dRow["BARCODE"] = data.BARCODE;
                dRow["ABBNAME"] = data.ABBNAME;
                dRow["MULTIPLY"] = data.MULTIPLY;
                dRow["ACTIVE"] = data.ACTIVE;
                dRow["UNITMASTER"] = data.UNITMASTER;
                dRow["UNIT"] = data.UNIT;
                dRow["COST"] = data.COST;
                dRow["PRICE"] = data.PRICE;
                dRow["STDPRICE"] = data.STDPRICE;
                dRow["PACKSIZE"] = data.PACKSIZE;
                dRow["UNITPACK"] = data.UNITPACK;

                dt.Rows.Add(dRow);
                System.Web.HttpContext.Current.Session[sessionName] = dt;
            }
        }
        return ret;
    }
Esempio n. 6
0
 private bool VerifyData(ProductBarcodeData data)
 {
     bool ret = true;
     if (data.BARCODE == "")
     {
         ret = false;
         _error = "¡ÃسÒÃÐºØ Barcode";
     }
     else if (data.UNIT == 0)
     {
         ret = false;
         _error = "¡ÃسÒàÅ×͡˹èÇÂ";
     }
     else if (data.MULTIPLY < 1)
     {
         ret = false;
         _error = "¨Ó¹Ç¹µéͧÁÒ¡¡ÇèÒ 1";
     }
     else
     {
         DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName];
         foreach (DataRow dRow in dt.Rows)
         {
             if ((dRow["BARCODE"].ToString() == data.BARCODE) && (Convert.ToDouble(dRow["LOID"]) != data.LOID))
             {
                 _error = "ºÒÃìâ¤é´¹ÕéÁÕÍÂÙèáÅéÇ";
                 ret = false;
                 break;
             }
             if ((dRow["ABBNAME"].ToString() == data.ABBNAME) && (Convert.ToDouble(dRow["LOID"]) != data.LOID))
             {
                 _error = "ª×èÍÂè͹ÕéÁÕÍÂÙèáÅéÇ";
                 ret = false;
                 break;
             }
             if ((Convert.ToDouble(dRow["UNIT"]) == data.UNIT) && (Convert.ToDouble(dRow["LOID"]) != data.LOID))
             {
                 _error = "ÃÒ¡ÒÃÊÔ¹¤éÒ·Õèãªé˹èǹѺ¹ÕéÁÕÍÂÙèáÅéÇ";
                 ret = false;
                 break;
             }
         }
     }
     return ret;
 }