public CtrlDeliveryItemData GetRequisition(double requisition, string invcode) { string where = ""; if (requisition != 0) where += (where == "" ? "" : "AND ") + "LOID = " + requisition.ToString() + " "; if (invcode.Trim() != "") where += (where == "" ? "" : "AND ") + "UPPER(INVCODE) = '" + invcode.Trim().ToUpper() + "' "; string sql = "SELECT LOID, INVCODE, REFTYPELOID, TYPENAME, CUSTOMERNAME, CADDRESS, CTEL, CONTACTNAME "; sql += "FROM V_INVOICE_FOR_DELIVERLY "; sql += (where == "" ? "" : "WHERE ") + where + " "; DataTable dt = OracleDB.ExecListCmd(sql); CtrlDeliveryItemData data = new CtrlDeliveryItemData(); if (dt.Rows.Count == 1) { DataRow dRow = dt.Rows[0]; if (!Convert.IsDBNull(dRow["CADDRESS"])) data.CADDRESS = dRow["CADDRESS"].ToString(); if (!Convert.IsDBNull(dRow["CUSTOMERNAME"])) data.CNAME = dRow["CUSTOMERNAME"].ToString(); if (!Convert.IsDBNull(dRow["CONTACTNAME"])) data.CONTACTNAME = dRow["CONTACTNAME"].ToString(); if (!Convert.IsDBNull(dRow["CTEL"])) data.CTEL = dRow["CTEL"].ToString(); if (!Convert.IsDBNull(dRow["INVCODE"])) data.INVCODE = dRow["INVCODE"].ToString(); if (!Convert.IsDBNull(dRow["LOID"])) data.REQUISITION = Convert.ToDouble(dRow["LOID"]); } return data; }
protected void grvItem_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtBoxQty = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[4].FindControl("txtBoxQty"); TextBox txtInvcode = (TextBox)this.grvItem.Rows[e.RowIndex].Cells[2].FindControl("txtInvcode"); CtrlDeliveryItemData data = new CtrlDeliveryItemData(); data.BOXQTY = Convert.ToDouble(txtBoxQty.Text == "" ? "0" : txtBoxQty.Text); data.INVCODE = txtInvcode.Text; e.NewValues["LOID"] = this.grvItem.Rows[e.RowIndex].Cells[5].Text; e.NewValues["BOXQTY"] = data.BOXQTY.ToString(); e.NewValues["INVCODE"] = data.INVCODE; }
protected void grvItem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Insert") { TextBox txtBoxQty = (TextBox)this.grvItem.FooterRow.Cells[4].FindControl("txtNewBoxQty"); TextBox txtRequisition = (TextBox)this.grvItem.FooterRow.Cells[2].FindControl("txtNewRequisition"); TextBox txtInvcode = (TextBox)this.grvItem.FooterRow.Cells[2].FindControl("txtNewInvcode"); CtrlDeliveryItemData data = new CtrlDeliveryItemData(); data.REQUISITION = Convert.ToDouble(txtRequisition.Text == "" ? "0" : txtRequisition.Text); data.BOXQTY = Convert.ToDouble(txtBoxQty.Text == "" ? "0" : txtBoxQty.Text); data.INVCODE = txtInvcode.Text; if (ItemObj.InsertRequisitionItem(data)) { SetGrvItem(); } else Appz.ClientAlert(this, ItemObj.ErrorMessage); } else if (e.CommandName == "EditSearch") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).Parent.Parent).RowIndex; TextBox txtInvCode = (TextBox)this.grvItem.Rows[rowIndex].Cells[4].FindControl("txtInvcode"); TextBox txtBoxQty = (TextBox)this.grvItem.Rows[rowIndex].Cells[4].FindControl("txtBoxQty"); Label txtContactName = (Label)this.grvItem.Rows[rowIndex].Cells[3].FindControl("txtContactName"); Label txtCname = (Label)this.grvItem.Rows[rowIndex].Cells[3].FindControl("txtCname"); Label txtAddress = (Label)this.grvItem.Rows[rowIndex].Cells[3].FindControl("txtAddress"); Label txtTel = (Label)this.grvItem.Rows[rowIndex].Cells[3].FindControl("txtTel"); TextBox txtRequisition = (TextBox)this.grvItem.Rows[rowIndex].Cells[2].FindControl("txtRequisition"); CtrlDeliveryItemData data = FlowObj.GetRequisition(Convert.ToDouble(txtRequisition.Text == "" ? "0" : txtRequisition.Text), txtInvCode.Text.Trim()); txtInvCode.Text = data.INVCODE; txtContactName.Text = data.CONTACTNAME; txtCname.Text = data.CNAME; txtAddress.Text = data.CADDRESS; txtTel.Text = data.CTEL; txtRequisition.Text = data.REQUISITION.ToString(); } else if (e.CommandName == "Search") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).Parent.Parent).RowIndex; TextBox txtInvCode = (TextBox)this.grvItem.FooterRow.Cells[4].FindControl("txtNewInvcode"); TextBox txtBoxQty = (TextBox)this.grvItem.FooterRow.Cells[4].FindControl("txtNewBoxQty"); Label txtContactName = (Label)this.grvItem.FooterRow.Cells[3].FindControl("txtNewContactName"); Label txtCname = (Label)this.grvItem.FooterRow.Cells[3].FindControl("txtNewCname"); Label txtAddress = (Label)this.grvItem.FooterRow.Cells[3].FindControl("txtNewAddress"); Label txtTel = (Label)this.grvItem.FooterRow.Cells[3].FindControl("txtNewTel"); TextBox txtRequisition = (TextBox)this.grvItem.FooterRow.Cells[2].FindControl("txtNewRequisition"); CtrlDeliveryItemData data = FlowObj.GetRequisition(Convert.ToDouble(txtRequisition.Text == "" ? "0" : txtRequisition.Text), txtInvCode.Text.Trim()); txtInvCode.Text = data.INVCODE; txtContactName.Text = data.CONTACTNAME; txtCname.Text = data.CNAME; txtAddress.Text = data.CADDRESS; txtTel.Text = data.CTEL; txtRequisition.Text = data.REQUISITION.ToString(); } }
public bool UpdateDeliveryItem(decimal LOID,decimal RANK, decimal REQUISITION, decimal BOXQTY, string INVCODE, string CONTACTNAME, string CNAME, string CADDRESS, string CTEL) { CtrlDeliveryItemData data = new CtrlDeliveryItemData(); data.LOID = Convert.ToDouble(LOID); data.REQUISITION = Convert.ToDouble(REQUISITION); data.BOXQTY = Convert.ToDouble(BOXQTY); data.INVCODE = INVCODE.ToString(); data.CONTACTNAME = CONTACTNAME.ToString(); data.CNAME = CNAME.ToString(); data.CADDRESS = CADDRESS.ToString(); data.CTEL = (CTEL == null ? "" : CTEL.ToString()); 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["INVCODE"] = data.INVCODE; dRow["BOXQTY"] = data.BOXQTY; CtrlDeliveryItemData requisition = FlowObj.GetRequisition(data.REQUISITION, data.INVCODE); dRow["CONTACTNAME"] = data.CONTACTNAME; dRow["CNAME"] = data.CNAME; dRow["CADDRESS"] = data.CADDRESS; dRow["CTEL"] = data.CTEL; dRow["REQUISITION"] = requisition.REQUISITION; ReOrder(dt); System.Web.HttpContext.Current.Session[sessionName] = dt; } } else throw new ApplicationException(_error); return ret; }
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) { CtrlDeliveryItemData data = new CtrlDeliveryItemData(); data.BOXQTY = Convert.ToDouble(dRow["BOXQTY"]); data.LOID = Convert.ToDouble(dRow["LOID"]); data.CADDRESS = dRow["CADDRESS"].ToString(); data.CNAME = dRow["CNAME"].ToString(); data.CONTACTNAME = dRow["CONTACTNAME"].ToString(); data.CTEL = dRow["CTEL"].ToString(); data.REQUISITION = Convert.ToDouble(dRow["REQUISITION"]); arr.Add(data); } } return arr; }
//0 LOID, 0 PRODUCT, 0 QTY, 0 UNIT, 0 PRICE, 0 DISCOUNT, 0 NETPRICE, '" + Constz.ActiveStatus.Active + "' ACTIVE, '' BARCODE, '' UNITNAME, '' ISVAT "; public bool InsertRequisitionItem(CtrlDeliveryItemData 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["INVCODE"] = data.INVCODE; dRow["BOXQTY"] = Convert.ToDouble(data.BOXQTY); CtrlDeliveryItemData requisition = FlowObj.GetRequisition(data.REQUISITION, data.INVCODE); dRow["REQUISITION"] = requisition.REQUISITION; dRow["CONTACTNAME"] = requisition.CONTACTNAME; dRow["CNAME"] = requisition.CNAME; dRow["CADDRESS"] = requisition.CADDRESS; dRow["CTEL"] = requisition.CTEL; dt.Rows.Add(dRow); System.Web.HttpContext.Current.Session[sessionName] = dt; } } return ret; }
private bool VerifyData(CtrlDeliveryItemData data) { bool ret = true; if (data.REQUISITION == 0) { ret = false; _error = "¡ÃسÒÃкØàÅ¢·Õè Invoice "; } else if (data.INVCODE == "") { ret = false; _error = "¡ÃسҵÃǨÊͺàÅ¢·Õè Invoice "; } else if (data.BOXQTY == 0) { ret = false; _error = "¡ÃسÒÃкبӹǹ¡Åèͧ"; } else { DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName]; if (dt != null) { foreach (DataRow dRow in dt.Rows) { if (Convert.ToDouble(dRow["REQUISITION"]) == data.REQUISITION && Convert.ToDouble(dRow["LOID"]) != data.LOID) { _error = "àÅ¢·Õè Invoice ¹ÕéÁÕÍÂÙèã¹ÃÒ¡ÒÃáÅéÇ"; ret = false; goto ex; } } } ex: ; } return ret; }