public int calculateBalance(string stCardId, int adjQty)
        {
            StockCardDetailEnt stCardDetailEnt1 = new StockCardDetailEnt();
            StockCard_Detail stCardDetail1 = new StockCard_Detail();

            stCardDetail1.StockCard_ID = stCardId;
            int bal= (int)stCardDetailEnt1.getStockCardDetail(stCardDetail1).First().Balance;
            int adjustedQty = bal + adjQty;
            return adjustedQty;
        }
        public List<StockCard_Detail> getStockCardDetail(StockCard_Detail sd)
        {
            var q = from s in ContextDB.StockCard_Detail
                    where (s.StockCard_ID == sd.StockCard_ID || sd.StockCard_ID == null)
                    && (s.Tran_ID == sd.Tran_ID || sd.Tran_ID == null)
                    && (s.Emp_ID == sd.Emp_ID || sd.Emp_ID == null)
                    && (s.Date == sd.Date || sd.Date == null)
                    && (s.Dept_Supplier == sd.Dept_Supplier || sd.Dept_Supplier == null)
                    && (s.Qty == sd.Qty || sd.Qty == null)
                    && (s.Balance == sd.Balance || sd.Balance == null)
                    select s;

            return q.ToList<StockCard_Detail>();
        }
        public void updateStock(string vocID, string itemCode, int adjQty, string userId, DateTime date)
        {
            StockCardDetailEnt stCardDetailEnt = new StockCardDetailEnt();
            StockCard_Detail stCardDetail = new StockCard_Detail();

            string stCardId = getStockCardID(itemCode);
            stCardDetail.StockCard_ID=stCardId;
            stCardDetail.Tran_ID= getTransactionID("StockCard_Detail");
            stCardDetail.Emp_ID=userId;
            stCardDetail.Date=date;
            stCardDetail.Dept_Supplier=stCardDetail.Dept_Supplier;
            stCardDetail.Qty=adjQty;
            stCardDetail.Balance= calculateBalance(stCardId, adjQty);
            stCardDetailEnt.createStockCardDetail(stCardDetail);
        }
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            rNolist = (List<string>)Session["ReqNoList"];

            foreach (string rN in rNolist) {

                Disbursement newD = new Disbursement();
                string newDisId = d.Generate_ID("Disbursement");
                newD.Disbursement_ID = newDisId;
                newD.Req_Form_No = rN;
                newD.Dept_ID = rN.Substring(0, 3);
                newD.Date = DateTime.Now;
                newD.Disburse_Status = 1;

                eb.insertDis(newD);//--------------eb
                d.update_GenID("Disbursement");
                eb.updateApproval_Status(rN);//----------------eb

                List<Requisition_Detail> rdli = new List<Requisition_Detail>();
                rdli = eb.getItemCodeFromReq(rN);//--------------eb

                foreach (Requisition_Detail rd in rdli) {
                    Disbursement_Detail newDD = new Disbursement_Detail();
                    newDD.Disbursement_ID = newDisId;
                    newDD.Item_Code = rd.Item_Code;
                    newDD.Qty_Required = rd.Qty;

                    int retri_Qty = 0;
                    foreach (GridViewRow row in GridView2.Rows) {
                        if ((row.Cells[1].Text.ToString() == rN) && (row.Cells[0].Text.ToString() == rd.Item_Code))
                        {
                            retri_Qty = int.Parse(row.Cells[3].Text.ToString());
                        }
                        else retri_Qty = 0;
                    }
                    newDD.Qty_Retrieved = retri_Qty;
                    newDD.Qty_Disbursed = retri_Qty;
                    eb.insertDisD(newDD);//-------------eb

                    StockCard_Detail newSD = new StockCard_Detail();
                    string newTranId = d.Generate_ID("StockCard_Detail");
                    newSD.StockCard_ID = eb.getSCIDFromItemCode(rd.Item_Code);//-------------eb
                    newSD.Tran_ID = newTranId;
                    newSD.Emp_ID = "Emp01";
                    newSD.Date = DateTime.Now;
                    newSD.Dept_Supplier = rN.Substring(0, 3);
                    newSD.Qty = - retri_Qty;
                    newSD.Balance = eb.getBalance_From_ItemCode(rd.Item_Code) - retri_Qty;

                    eb.insertStock_Detail(newSD);//-----------------eb
                    d.update_GenID("StockCard_Detail");
                }
            }
        }
 //----------------
 public int updateStock_Detail(string itemCode,int qty)
 {
     var v = (from sm in entity.StockCards
             where sm.Item_Code == itemCode
             join sdm in entity.StockCard_Detail on sm.StockCard_ID equals sdm.StockCard_ID
             select new
             {
                 Qty = sdm.Balance
             }).SingleOrDefault();
     StockCard_Detail newsdm = new StockCard_Detail();
     newsdm.Balance = newsdm.Balance - v.Qty;
     int i = entity.SaveChanges();
     return i;
 }
 //------Outstanding
 //------Retrieval................
 public int insertStock_Detail(StockCard_Detail newSD)
 {
     entity.StockCard_Detail.AddObject(newSD);
     int i = entity.SaveChanges();
     return i;
 }
        protected void btnFulfil_Click(object sender, EventArgs e)
        {
            foreach (string disNU in disIdUniq) {

                Disbursement newDis = new Disbursement();
                string newDisID = d.Generate_ID("Disbursement");
                newDis.Disbursement_ID = newDisID;
                newDis.Req_Form_No = eb.getReqNo_From_DisID(disNU);//-------------eb
                newDis.Dept_ID = eb.getDeptIdFromDisId(disNU);//--------------eb
                newDis.Date = DateTime.Now;
                newDis.Disburse_Status = 1;
                eb.insertDis(newDis);//-------------eb

                d.update_GenID("Disbursement");

                List<Disbursement_Detail> ddli = new List<Disbursement_Detail>();
                ddli = eb.getDDItemFromDisN(disNU);//-------------eb

                foreach (Disbursement_Detail dd in ddli)
                {
                    foreach (GridViewRow row in GridView1.Rows)
                    {
                        string itemC = row.Cells[1].Text.ToString();
                        if (dd.Item_Code == itemC)
                        {
                            Disbursement_Detail newDD = new Disbursement_Detail();
                            newDD.Disbursement_ID = newDisID;
                            newDD.Item_Code = itemC;
                            newDD.Qty_Required = dd.Qty_Required - dd.Qty_Disbursed;
                            newDD.Qty_Retrieved = dd.Qty_Required - dd.Qty_Disbursed;
                            newDD.Qty_Disbursed = dd.Qty_Required - dd.Qty_Disbursed;
                            eb.insertDisD(newDD);//--------eb
                            eb.updateQty_Disbursed(disNU,itemC);//----------eb

                            StockCard_Detail newSD = new StockCard_Detail();
                            string newTranId = d.Generate_ID("StockCard_Detail");
                            newSD.StockCard_ID = eb.getSCIDFromItemCode(dd.Item_Code);
                            newSD.Tran_ID = newTranId;
                            newSD.Emp_ID = "Emp01";
                            newSD.Date = DateTime.Now;
                            newSD.Dept_Supplier = eb.getDeptIdFromDisId(disNU);
                            newSD.Qty = -(dd.Qty_Required - dd.Qty_Disbursed);
                            newSD.Balance = eb.getBalance_From_ItemCode(dd.Item_Code) - (dd.Qty_Required - dd.Qty_Disbursed);

                            eb.insertStock_Detail(newSD);
                            d.update_GenID("StockCard_Detail");
                        }
                    }
                }

                if (!eb.checkOutS(disNU))//----------eb
                {
                    eb.updateDisburse_Status3to2(disNU);//-----------eb
                }
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the StockCard_Detail EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStockCard_Detail(StockCard_Detail stockCard_Detail)
 {
     base.AddObject("StockCard_Detail", stockCard_Detail);
 }
 /// <summary>
 /// Create a new StockCard_Detail object.
 /// </summary>
 /// <param name="stockCard_ID">Initial value of the StockCard_ID property.</param>
 /// <param name="tran_ID">Initial value of the Tran_ID property.</param>
 public static StockCard_Detail CreateStockCard_Detail(global::System.String stockCard_ID, global::System.String tran_ID)
 {
     StockCard_Detail stockCard_Detail = new StockCard_Detail();
     stockCard_Detail.StockCard_ID = stockCard_ID;
     stockCard_Detail.Tran_ID = tran_ID;
     return stockCard_Detail;
 }
示例#10
0
 public int insertStock_Detail(StockCard_Detail newSD)
 {
     return eb.insertStock_Detail(newSD);
 }
 public void createStockCardDetail(StockCard_Detail sd)
 {
     ContextDB.StockCard_Detail.AddObject(sd);
     ContextDB.SaveChanges();
 }