private bool VerifyData(BomData data) { bool ret = true; if (data.MATERIAL == 0) { ret = false; _error = "¡ÃسÒàÅ×Í¡Çѵ¶Ø´Ôº"; } else if (data.MASTER == 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["LOID"]) == data.MATERIAL && Convert.ToDouble(dRow["RANK"]) != data.LOID) { ret = false; _error = "Çѵ¶Ø´Ôº«éÓ"; break; } } } } return ret; }
//0 LOID, 0 PRODUCT, 0 QTY, 0 UNIT, 0 PRICE, 0 DISCOUNT, 0 NETPRICE, '" + Constz.ActiveStatus.Active + "' ACTIVE, '' BARCODE, '' UNITNAME, '' ISVAT "; public bool InsertBomItem(string BARCODE, string NAME, double MASTER, string PRODUCTTYPE, string UNITNAME, double UNIT, double MATERIAL) { bool ret = true; BomData data = new BomData(); data.CODE = BARCODE; data.MASTER = Convert.ToDouble(MASTER); data.MATERIAL = Convert.ToDouble(MATERIAL); data.UNIT = Convert.ToDouble(UNIT); ret = VerifyData(data); if (ret) { DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName]; if (dt != null) { ReOrder(dt); DataRow dRow = dt.NewRow(); dRow["RANK"] = Convert.ToDouble(dt.Rows.Count) + 1; dRow["BARCODE"] = data.CODE; dRow["NAME"] = NAME; dRow["MASTER"] = data.MASTER; dRow["PRODUCTTYPE"] = PRODUCTTYPE; dRow["UNITNAME"] = UNITNAME; dRow["UNIT"] = data.UNIT; dRow["LOID"] = Convert.ToDouble(data.MATERIAL); dt.Rows.Add(dRow); System.Web.HttpContext.Current.Session[sessionName] = dt; } } 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) { BomData data = new BomData(); data.MASTER = Convert.ToDouble(dRow["MASTER"]); data.MATERIAL = Convert.ToDouble(dRow["LOID"]); data.UNIT = Convert.ToDouble(dRow["UNIT"]); arr.Add(data); } } return arr; }
public bool UpdateBomItem(decimal RANK, string BARCODE, string NAME, decimal MASTER, string PRODUCTTYPE, string UNITNAME, decimal UNIT, decimal LOID) { BomData data = new BomData(); data.LOID = Convert.ToDouble(RANK); data.CODE = BARCODE; data.MASTER = Convert.ToDouble(MASTER); data.MATERIAL = Convert.ToDouble(LOID); data.UNIT = Convert.ToDouble(UNIT); bool ret = true; ret = VerifyData(data); if (ret) { DataTable dt = (DataTable)System.Web.HttpContext.Current.Session[sessionName]; if (dt != null) { DataRow[] dRows = dt.Select("RANK = " + data.LOID.ToString()); DataRow dRow = dRows[0]; dRow["BARCODE"] = data.CODE; dRow["NAME"] = NAME; dRow["MASTER"] = data.MASTER; dRow["PRODUCTTYPE"] = PRODUCTTYPE; dRow["UNITNAME"] = UNITNAME; dRow["UNIT"] = data.UNIT; dRow["LOID"] = Convert.ToDouble(data.MATERIAL); ReOrder(dt); System.Web.HttpContext.Current.Session[sessionName] = dt; } } else throw new ApplicationException(_error); return ret; }