public StockinReturnItemData GetReqmaterialBarcode(double refloid, string barcode) { string sql = "SELECT RM.LOID, ROWNUM RANK , RM.PRODUCT, PD.BARCODE, PD.NAME PDNAME, '' LOTNO, RM.RETURNQTY QTY, RM.UNIT, UN.NAME UNITNAME, RM.LOID REFLOID, 'REQMATERIAL' REFTABLE, 'WA' STATUS, PD.PRICE, PD.PRICE*RM.RETURNQTY AS NETPRICE "; sql += "FROM REQMATERIAL RM "; sql += "INNER JOIN PRODUCT PD ON PD.LOID=RM.PRODUCT "; sql += "INNER JOIN UNIT UN ON UN.LOID=RM.UNIT "; sql += "WHERE RM.REQUISITION = " + refloid + " AND PD.BARCODE = " + barcode; DataTable dt = OracleDB.ExecListCmd(sql); StockinReturnItemData data = new StockinReturnItemData(); if (dt.Rows.Count > 0) { data.BARCODE = dt.Rows[0]["BARCODE"].ToString(); data.QTY = Convert.ToDouble(dt.Rows[0]["QTY"]); data.UNITNAME = dt.Rows[0]["UNITNAME"].ToString(); data.PRICE = Convert.ToDouble(dt.Rows[0]["PRICE"]); data.PRODUCT = Convert.ToDouble(dt.Rows[0]["PRODUCT"]); data.REFLOID = Convert.ToDouble(dt.Rows[0]["REFLOID"]); data.UNIT = Convert.ToDouble(dt.Rows[0]["UNIT"]); } return data; }
protected void grvItem_RowCommand(object sender, GridViewCommandEventArgs e) { ImageButton img = (ImageButton)e.CommandSource; Int16 rowIndex = (Int16)((GridViewRow)img.Parent.Parent).RowIndex; GridViewRow commandRow; if (rowIndex >= 0) { commandRow = this.grvItem.Rows[rowIndex]; } else { commandRow = this.grvItem.FooterRow; } TextBox txtBarCode = (TextBox)commandRow.Cells[2].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtBarCode" : "txtNewBarCode"); TextBox txtProduct = (TextBox)commandRow.Cells[3].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtProduct" : "txtNewProduct"); TextBox txtLotNo = (TextBox)commandRow.Cells[4].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtLotNo" : "txtNewLotNo"); TextBox txtQty = (TextBox)commandRow.Cells[5].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtQty" : "txtNewQty"); TextBox txtLostQty = (TextBox)commandRow.Cells[6].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtLostQty" : "txtLostNewQty"); TextBox txtUnit = (TextBox)commandRow.Cells[7].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtUnit" : "txtNewUnit"); TextBox txtPrice = (TextBox)commandRow.Cells[8].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtPrice" : "txtNewPrice"); TextBox txtNetPrice = (TextBox)commandRow.Cells[9].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtNetPrice" : "txtNewNetPrice"); TextBox txtOldQty = (TextBox)commandRow.Cells[10].FindControl(commandRow.RowType == DataControlRowType.DataRow ? "txtOldQty" : "txtOldNewQty"); if (e.CommandName == "Insert") { StockinReturnItemData data = new StockinReturnItemData(); data.BARCODE = txtBarCode.Text; data.PDNAME = txtProduct.Text; data.LOTNO = txtLotNo.Text; data.QTY = Convert.ToDouble(txtQty.Text == "" ? "0" : txtQty.Text); data.QTYLOST = Convert.ToDouble(txtLostQty.Text == "" ? "0" : txtLostQty.Text); data.UNITNAME = txtUnit.Text; data.PRICE = Convert.ToDouble(txtPrice.Text == "" ? "0" : txtPrice.Text); data.NETPRICE = data.PRICE * (data.QTY+ data.QTYLOST); data.OLDQTY = Convert.ToDouble(txtOldQty.Text == "" ? "0" : txtOldQty.Text); data.PRODUCT = Convert.ToDouble(commandRow.Cells[12].Text); data.UNIT = Convert.ToDouble(commandRow.Cells[13].Text); data.REFLOID = Convert.ToDouble(commandRow.Cells[14].Text); data.REFTABLE = commandRow.Cells[15].Text; data.STATUS = commandRow.Cells[16].Text; if (ItemObj.InsertItem(data)) { SetGrvItem(this.txtStatus.Text); Calculation(); } else Appz.ClientAlert(this, ItemObj.ErrorMessage); } else if (e.CommandName == "Search") { TextBox txtGetData = (TextBox)commandRow.Cells[2].FindControl("txtGetData"); string[] str = txtGetData.Text.Split(';'); DataTable dt = new DataTable(); if (cmbDocType.SelectedValue == Constz.DocType.RetInSample.LOID.ToString()) { dt = FlowObj.GetReturnWaitListRefLoid(str[0], str[1]); } else { dt = FlowObj.GetViewReturnWaitList(str[0], str[1]); } if (dt.Rows.Count > 0) { txtBarCode.Text = dt.Rows[0]["BARCODE"].ToString(); txtProduct.Text = dt.Rows[0]["PDNAME"].ToString(); txtLotNo.Text = dt.Rows[0]["LOTNO"].ToString(); txtQty.Text = dt.Rows[0]["QTY"].ToString(); txtLostQty.Text = dt.Rows[0]["QTYLOST"].ToString(); txtUnit.Text = dt.Rows[0]["UNAME"].ToString(); txtPrice.Text = dt.Rows[0]["PRICE"].ToString(); txtNetPrice.Text = dt.Rows[0]["NETPRICE"].ToString(); txtOldQty.Text = dt.Rows[0]["OLDQTY"].ToString(); commandRow.Cells[12].Text = str[0]; commandRow.Cells[13].Text = dt.Rows[0]["ULOID"].ToString(); commandRow.Cells[14].Text = dt.Rows[0]["REFLOID"].ToString(); commandRow.Cells[15].Text = dt.Rows[0]["REFTABLE"].ToString(); commandRow.Cells[16].Text = Constz.Requisition.Status.Waiting.Code; } } }
protected void grvItem_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtBarCode = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[2].FindControl("txtBarCode"); TextBox txtProduct = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[3].FindControl("txtProduct"); TextBox txtLotNo = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[4].FindControl("txtLotNo"); TextBox txtQty = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[5].FindControl("txtQty"); TextBox txtLostQty = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[6].FindControl("txtLostQty"); TextBox txtUnit = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtUnit"); TextBox txtPrice = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtPrice"); TextBox txtOldQty = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[10].FindControl("txtOldQty"); StockinReturnItemData data = new StockinReturnItemData(); data.BARCODE = txtBarCode.Text; data.PDNAME = txtProduct.Text; data.LOTNO = txtLotNo.Text; data.QTY = Convert.ToDouble(txtQty.Text == "" ? "0" : txtQty.Text); data.QTYLOST = Convert.ToDouble(txtLostQty.Text == "" ? "0" : txtLostQty.Text); data.UNITNAME = txtUnit.Text; data.PRICE = Convert.ToDouble(txtPrice.Text); data.NETPRICE = (data.QTY + data.QTYLOST)* data.PRICE; data.OLDQTY = Convert.ToDouble(txtOldQty.Text == "" ? "0" : txtOldQty.Text); e.NewValues["BARCODE"] = data.BARCODE; e.NewValues["PDNAME"] = data.PDNAME; e.NewValues["LOTNO"] = data.LOTNO; e.NewValues["QTY"] = data.QTY.ToString(); e.NewValues["QTYLOST"] = data.QTYLOST.ToString(); e.NewValues["UNITNAME"] = data.UNITNAME; e.NewValues["PRICE"] = data.PRICE.ToString(); e.NewValues["NETPRICE"] = data.NETPRICE.ToString(); e.NewValues["OLDQTY"] = data.OLDQTY.ToString(); if (this.grvItem.Rows[e.RowIndex].Cells[12].Text != "") { e.NewValues["PRODUCT"] = this.grvItem.Rows[e.RowIndex].Cells[12].Text; e.NewValues["UNIT"] = this.grvItem.Rows[e.RowIndex].Cells[13].Text; e.NewValues["REFLOID"] = this.grvItem.Rows[e.RowIndex].Cells[14].Text; e.NewValues["REFTABLE"] = this.grvItem.Rows[e.RowIndex].Cells[15].Text; e.NewValues["STATUS"] = this.grvItem.Rows[e.RowIndex].Cells[16].Text; } Calculation(); }
protected void grvItem_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtBarcode = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[2].FindControl("txtBarcode"); DropDownList cmbLotNo = (DropDownList)this.grvItem.Rows[e.RowIndex].Cells[4].FindControl("cmbLotNo"); DropDownList cmbProduct = (DropDownList)this.grvItem.Rows[e.RowIndex].Cells[3].FindControl("cmbProduct"); TextBox txtQty = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[6].FindControl("txtQty"); TextBox txtUnit = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtUnit"); Label lblUnitName = (Label)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("lblUnitName"); TextBox txtPrice = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtPrice"); TextBox txtRefLOID = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[7].FindControl("txtRefLOID"); StockinReturnItemData data = new StockinReturnItemData(); data.BARCODE = txtBarcode.Text.Trim(); data.LOTNO = cmbLotNo.SelectedItem.Value; data.PRICE = Convert.ToDouble(txtPrice.Text == "" ? "0" : txtPrice.Text); data.PRODUCT = Convert.ToDouble(cmbProduct.SelectedItem.Value); data.QTY = Convert.ToDouble(txtQty.Text == "" ? "0" : txtQty.Text); data.REFLOID = Convert.ToDouble(txtRefLOID.Text == "" ? "0" : txtRefLOID.Text); data.UNIT = Convert.ToDouble(txtUnit.Text == "" ? "0" : txtUnit.Text); data.UNITNAME = lblUnitName.Text.Trim(); e.NewValues["BARCODE"] = data.BARCODE; e.NewValues["PRODUCT"] = data.PRODUCT.ToString(); e.NewValues["LOTNO"] = data.LOTNO; e.NewValues["QTY"] = data.QTY.ToString(); e.NewValues["UNIT"] = data.UNIT.ToString(); e.NewValues["PRICE"] = data.PRICE.ToString(); e.NewValues["UNITNAME"] = data.UNITNAME; e.NewValues["REFLOID"] = data.REFLOID; }
private void InsertData(GridViewRow gRow) { TextBox txtBarcode = (TextBox)gRow.Cells[2].FindControl("txtBarcodeNew"); DropDownList cmbLotNo = (DropDownList)gRow.Cells[4].FindControl("cmbLotNoNew"); DropDownList cmbProduct = (DropDownList)gRow.Cells[3].FindControl("cmbProductNew"); TextBox txtQty = (TextBox)gRow.Cells[6].FindControl("txtQtyNew"); TextBox txtUnit = (TextBox)gRow.Cells[7].FindControl("txtUnitNew"); Label lblUnitName = (Label)gRow.Cells[7].FindControl("lblUnitNameNew"); TextBox txtPrice = (TextBox)gRow.Cells[7].FindControl("txtPriceNew"); TextBox txtRefLOID = (TextBox)gRow.Cells[7].FindControl("txtRefLOIDNew"); StockinReturnItemData data = new StockinReturnItemData(); data.BARCODE = txtBarcode.Text.Trim(); data.LOTNO = cmbLotNo.SelectedItem.Value; data.PRICE = Convert.ToDouble(txtPrice.Text == "" ? "0" : txtPrice.Text); data.PRODUCT = Convert.ToDouble(cmbProduct.SelectedItem.Value); data.QTY = Convert.ToDouble(txtQty.Text == "" ? "0" : txtQty.Text); data.REFLOID = Convert.ToDouble(txtRefLOID.Text == "" ? "0" : txtRefLOID.Text); data.UNIT = Convert.ToDouble(txtUnit.Text == "" ? "0" : txtUnit.Text); data.UNITNAME = lblUnitName.Text.Trim(); // data.REQUISITION = Convert.ToDouble(this.txtRefLoid.Text == "" ? "0" : this.txtRefLoid.Text); if (ItemObj.InsertItem(data)) { SetGrvItem(this.txtStatus.Text); } else Appz.ClientAlert(this, ItemObj.ErrorMessage); }
private void SetProductDetail(StockinReturnItemData data, GridViewRow gRow, TextBox txtBarcode, DropDownList cmbProduct, DropDownList cmbLotNo, TextBox txtUnit, Label lblUnitName, TextBox txtPrice, TextBox txtQty, TextBox txtRef) { txtBarcode.Text = data.BARCODE; cmbProduct.SelectedIndex = cmbProduct.Items.IndexOf(cmbProduct.Items.FindByValue(data.PRODUCT.ToString())); txtUnit.Text = data.UNIT.ToString(); lblUnitName.Text = data.UNITNAME; txtPrice.Text = data.PRICE.ToString(Constz.DblFormat); txtQty.Text = data.QTY.ToString(Constz.IntFormat); txtRef.Text = data.REFLOID.ToString(); SetProductStock(cmbLotNo, data.PRODUCT); //if (txtBarcode.ID == "txtBarcodeNew" && txtBarcode.Text != "") // InsertData(gRow); }
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) { StockinReturnItemData data = new StockinReturnItemData(); data.LOID = Convert.ToDouble(dRow["LOID"]); data.PRODUCT = Convert.ToDouble(dRow["PRODUCT"]); data.LOTNO = dRow["LOTNO"].ToString(); data.QTY = Convert.ToDouble(dRow["QTY"]); data.QTYLOST = Convert.ToDouble(dRow["QTYLOST"]); data.UNIT = Convert.ToDouble(dRow["UNIT"]); data.PRICE = Convert.ToDouble(dRow["PRICE"]); data.OLDQTY = Convert.ToDouble(dRow["OLDQTY"]); data.REFLOID = Convert.ToDouble(dRow["REFLOID"]); data.REFTABLE = dRow["REFTABLE"].ToString(); data.STATUS = dRow["STATUS"].ToString(); arr.Add(data); } } return arr; }
public bool InsertItem(StockinReturnItemData 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["RANK"] = Convert.ToDouble(dRow["LOID"]); dRow["PRODUCT"] = data.PRODUCT; dRow["BARCODE"] = data.BARCODE; dRow["PDNAME"] = data.PDNAME; dRow["LOTNO"] = data.LOTNO; dRow["QTY"] = data.QTY; dRow["QTYLOST"] = data.QTYLOST; dRow["UNIT"] = data.UNIT; dRow["UNITNAME"] = data.UNITNAME; dRow["PRICE"] = data.PRICE; dRow["NETPRICE"] = data.PRICE * (data.QTY + data.QTYLOST); dRow["OLDQTY"] = data.OLDQTY; dRow["REFLOID"] = data.REFLOID; dRow["REFTABLE"] = data.REFTABLE; dRow["STATUS"] = data.STATUS; dt.Rows.Add(dRow); System.Web.HttpContext.Current.Session[sessionName] = dt; } } return ret; }
private bool VerifyData(StockinReturnItemData data) { bool ret = true; DataTable dt; if (data.PRODUCT == 0) { ret = false; _error = "¡ÃسÒàÅ×Í¡ÊÔ¹¤éÒ"; } //else if (data.QTY == 0) //{ // ret = false; // _error = "¡ÃسÒÃкبӹǹ´Õ"; //} //else if (data.QTYLOST == 0) //{ // ret = false; // _error = "¡ÃسÒÃкبӹǹàÊÕÂ"; //} else if (data.LOTNO == "") { ret = false; _error = "¡ÃسÒÃÐºØ Lot No"; } else if (data.OLDQTY < data.QTYLOST) { ret = false; _error = "¨Ó¹Ç¹àÊÕÂà¡Ô¹¨Ó¹Ç¹ÊÔ¹¤éÒ·ÕèÁÕÍÂÙè"; } else if (data.OLDQTY < (data.QTY + data.QTYLOST)) { ret = false; _error = "¨Ó¹Ç¹à¡Ô¹¨Ó¹Ç¹ÊÔ¹¤éÒ·ÕèÁÕÍÂÙè"; } else { dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName]; foreach (DataRow dRow in dt.Rows) { if ((Convert.ToDouble(dRow["PRODUCT"]) == data.PRODUCT) && (dRow["LOTNO"].ToString() == data.LOTNO) && (Convert.ToDouble(dRow["LOID"]) != data.LOID)) { _error = "ÃÒ¡ÒÃÊÔ¹¤éÒ¹ÕéÁÕÍÂÙèã¹ÃÒ¡ÒÃáÅéÇ"; ret = false; break; } //else if ((Convert.ToDouble(dRow["QTY"]) < (data.QTY + data.QTYLOST))) //{ // _error = "¨Ó¹Ç¹à¡Ô¹¨Ó¹Ç¹ÊÔ¹¤éÒ·ÕèÁÕÍÂÙè"; // ret = false; // break; //} } } return ret; }
public bool UpdateItem(decimal LOID, decimal PRODUCT, string BARCODE, string PDNAME, string LOTNO, decimal QTY, decimal QTYLOST, decimal UNIT, string UNITNAME, decimal REFLOID, string REFTABLE, string STATUS, decimal PRICE, decimal NETPRICE, decimal OLDQTY, decimal RANK) { StockinReturnItemData data = new StockinReturnItemData(); data.LOID = Convert.ToDouble(LOID); data.PRODUCT = Convert.ToDouble(PRODUCT); data.LOTNO = LOTNO; data.QTY = Convert.ToDouble(QTY); data.QTYLOST = Convert.ToDouble(QTYLOST); data.OLDQTY = Convert.ToDouble(OLDQTY); 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["PRODUCT"] = PRODUCT; dRow["BARCODE"] = BARCODE; dRow["PDNAME"] = PDNAME; dRow["LOTNO"] = LOTNO; dRow["QTY"] = QTY; dRow["QTYLOST"] = QTYLOST; dRow["UNIT"] = UNIT; dRow["UNITNAME"] = UNITNAME; dRow["PRICE"] = PRICE; dRow["NETPRICE"] = NETPRICE; dRow["OLDQTY"] = OLDQTY; dRow["REFLOID"] = REFLOID; dRow["REFTABLE"] = REFTABLE; dRow["STATUS"] = STATUS; ReOrder(dt); System.Web.HttpContext.Current.Session[sessionName] = dt; } } else throw new ApplicationException(_error); return ret; }