//Submits the items that have been collected.
        protected void btn_submitCollectionList_Click(object sender, EventArgs e)
        {
            //validate if textbox value is less than ordered & inventory
            if (ValidatePreparedQty() < 0)
            {
                return;
            }

            //(1) tracking qty collected per item for all dpts, store in a list of Collection objs
            List <CollectionListItem> allDptCollectionList = new List <CollectionListItem>();

            foreach (GridViewRow gvr in gv_CollectionList.Rows)
            {
                string itemNumber = gvr.Cells[0].Text;

                TextBox tb         = (TextBox)gvr.FindControl("txt_QtyPrepared");
                int     qtyPrepped = Convert.ToInt32(tb.Text);

                CollectionListItem c = new CollectionListItem(itemNumber, qtyPrepped);
                allDptCollectionList.Add(c);
            }

            //(2) sort goods according to req_date - write to the distri / pending tables
            BusinessLogic.SortCollectedGoods(allDptCollectionList);

            //(3) deduct collected items from inventory
            BusinessLogic.DeductFromInventory(allDptCollectionList);

            LoadCollectionList();
            if (gv_CollectionList.Rows.Count == 0)
            {
                //(4) Redirect to Sorting Page if gridview has no more rows (no more items to collect)
                Response.Redirect("~/Protected/DisbursementSorting.aspx");
            }
        }
Esempio n. 2
0
        //when ready for collection is clicked
        protected void btn_readyForCollect_Click(object sender, EventArgs e)
        {
            //checks if qty collected is more than either what is in inventory or order qty
            if (ValidatePreparedQty() < 0)
            {
                return;
            }

            List <CollectionListItem> clList = new List <CollectionListItem>();

            foreach (GridViewRow gvr in gv_ViewRO.Rows)
            {
                string itemNumber = gvr.Cells[0].Text;

                TextBox tb         = (TextBox)gvr.FindControl("txt_QtyPrepared");
                int     qtyPrepped = Convert.ToInt32(tb.Text);

                CollectionListItem c = new CollectionListItem(itemNumber, qtyPrepped);
                clList.Add(c);
            }

            // (1) insert collection_details + (2) add RO Ids & their collection_id to requisition_disbursement_detail [table]
            string dptId   = (Label_ViewRO.Text).Substring(0, 4);
            int    placeId = BusinessLogic.GetPlaceIdFromDptId(dptId);

            /**
             * String s = TextBox2.Text;
             *  DateTime dt = DateTime.ParseExact(s, "dd-MM-yyyy", CultureInfo.InvariantCulture);
             *  String x = dt.ToString("yyyy-MMMM-dd");
             *  DateTime search = Convert.ToDateTime(x);
             */
            string   s              = TextBox_Collect_Date.Text;
            DateTime dt             = DateTime.ParseExact(s, "dd-MM-yyyy", CultureInfo.InvariantCulture);
            String   x              = dt.ToString("yyyy-MMMM-dd");
            DateTime collectionDate = Convert.ToDateTime(x);
            //DateTime collectionDate = DateTime.Parse(TextBox_Collect_Date.Text); //joel
            string ro_id = Label_ViewRO.Text.ToUpper();

            //updates tables & sends email
            BusinessLogic.SpecialRequestReadyUpdatesCDRDD(placeId, collectionDate, ro_id, dptId);

            // (3) change amounts in requisition_order_detail table
            BusinessLogic.ViewROSpecialRequestUpdateRODTable(clList, ro_id);


            // (4) deduct from inventory
            BusinessLogic.DeductFromInventory(clList);

            Response.Redirect("~/Protected/ViewROSpecialRequest.aspx");
        }