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
                }
            }
        }
        public Disbursement getDisbursement(Disbursement dis)
        {
            var query = from d in ContextDB.Disbursements
                        where (d.Disbursement_ID == dis.Disbursement_ID || dis.Disbursement_ID == null)
                        && (d.Req_Form_No == dis.Req_Form_No || dis.Req_Form_No == null)
                        && (d.Dept_ID == dis.Dept_ID || dis.Dept_ID == null)
                        && (d.Date == dis.Date || dis.Date == null)
                        && (d.Disburse_Status == dis.Disburse_Status || dis.Disburse_Status == null)
                        select d;

            return query.First();
        }
        public bool deleteDisbursement(Disbursement delDis)
        {
            try
            {
                ContextDB.Disbursements.DeleteObject(delDis);
                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
        public bool updateDisbursement(Disbursement updDis)
        {
            try
            {
                Disbursement dis = getDisbursement(updDis);
                dis.Disburse_Status = updDis.Disburse_Status;

                ContextDB.SaveChanges();

                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
 //when click 'submit'
 //------------OutStanding
 public void fulfillInsertDis(string disNo)
 {
     var v = (from dm in entity.Disbursements
              where dm.Disbursement_ID == disNo
              join rm in entity.Requisitions on dm.Req_Form_No equals rm.Req_Form_No
              select new
              {
                  Disbursement_ID = dm.Disbursement_ID + "F",
                  Req_Form_No = dm.Req_Form_No,
                  Dept_ID = dm.Dept_ID,
                  Date = DateTime.Today,
                  Disburse_Status = 1
              }).FirstOrDefault();
     Disbursement newDis = new Disbursement();
     newDis.Disbursement_ID = v.Disbursement_ID;
     newDis.Req_Form_No = v.Req_Form_No;
     newDis.Dept_ID = v.Dept_ID;
     newDis.Date = v.Date;
     newDis.Disburse_Status = v.Disburse_Status;
     entity.Disbursements.AddObject(newDis);
 }
        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");
                }
            }
        }
 //insert/create new row to disbursement when click 'Submit' at retrieval UI
 //----------Retrieval
 public int insertDisbursement(string reqNo, string newDisID)
 {
     Disbursement newDis = new Disbursement();
     newDis.Disbursement_ID = newDisID;
     newDis.Req_Form_No = reqNo;
     newDis.Dept_ID = reqNo.Substring(0, 3);
     newDis.Date = DateTime.Today;
     newDis.Disburse_Status = 1;
     entity.Disbursements.AddObject(newDis);
     int i = entity.SaveChanges();
     return i;
 }
 //=========Retrieval..........
 public int insertDis(Disbursement newDis)
 {
     entity.Disbursements.AddObject(newDis);
     int i = entity.SaveChanges();
     return i;
 }
 public void createDisbursement(Disbursement disburse)
 {
     ContextDB.Disbursements.AddObject(disburse);
     ContextDB.SaveChanges();
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Disbursements EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDisbursements(Disbursement disbursement)
 {
     base.AddObject("Disbursements", disbursement);
 }
 /// <summary>
 /// Create a new Disbursement object.
 /// </summary>
 /// <param name="disbursement_ID">Initial value of the Disbursement_ID property.</param>
 public static Disbursement CreateDisbursement(global::System.String disbursement_ID)
 {
     Disbursement disbursement = new Disbursement();
     disbursement.Disbursement_ID = disbursement_ID;
     return disbursement;
 }
Esempio n. 12
0
 public int insertDis(Disbursement newDis)
 {
     return eb.insertDis(newDis);
 }
        //insert/create new row to disbursement when click 'Submit' at retrieval UI
        public int insertDisbursement(string reqNo)
        {
            var disbursement = new Disbursement {
                Req_Form_No = reqNo,
                Dept_ID = reqNo.Substring(0,3),
                Date = DateTime.Today,
                Disburse_Status = 1
            };
            entity.Disbursements.AddObject(disbursement);

            int i = entity.SaveChanges();
            return i;
        }