public void getJSONByDepartmentAndItem(HttpContext context)
        {
            int deptId = Convert.ToInt32(context.Request.Form["deptId"]);
            int stationeryId = Convert.ToInt32(context.Request.Form["stationeryId"]);

            Fulfillment_View i = new FulfillmentController().actionGetFulfillmentViewByDepartmentAndStationery(deptId, stationeryId);
            MFulfillment_View m = new MFulfillment_View(i.id, i.department, i.stationery, i.stationery_name, i.requested_quantity, i.fulfill_quantity, i.unfulfill_quantity, (int)i.stock_control);

            context.Response.Write(JsonConvert.SerializeObject(m));
            context.Response.End();
        }
        public void actionUpdateToDisbursement(int req_dept, int stationery)
        {
            FulfillmentController fc = new FulfillmentController();

            rf = fc.actionGetFulfillmentByDepartmentAndStationery(req_dept, stationery);

            // -------------- Disbursement Table Process ----------
            disbursement = actionGetDisbursementByDepartmentAndTodayDate(req_dept);

            if (disbursement == null)
            {
                actionCreateDisbursementTable(req_dept, getDeptRept(req_dept));
            }

            disbursementId = actionGetDisbursementIdByDepartmentAndDate(req_dept, disbursement.distributed_date);


            // -------------- Disbursement Detail Table Process ----------
            disbursementDetail = actionGetDisbursementDetailByDepartmentAndStationery(stationery);

            if (disbursementDetail == null)
            {
                actionCreateDisbursementDetailTable();
            }
            else
            {
                actionUpdateDisbursementDetailTable();
            }

            // -------------- Update Stationery Process ----------
            new StationeryController().actionUpdateQty(rf.stationery, rf.fulfill_quantity);

            // -------------- Update StockTransaction Process ----------
            new StockTransactionController().actionCreateStockTransaction(stationery, new StationeryController().actionGetQtyInStock(stationery),
                                                                          "Disbursement", "- " + rf.fulfill_quantity.ToString());

            // -------------- Remaining Requisition Fulfillment Process ----------
            unfulfillQty = rf.requested_quantity - rf.fulfill_quantity;
            if (unfulfillQty == 0)
            {
                fc.actionDeleteFulfillmentByObject(rf);
            }
            else
            {
                fc.actionUpdateFulfillmentByObject(rf, unfulfillQty);
            }

            // -------------- Update Requisition Status Process ----------
            new RequisitionController().actionRequisitionStatusChangeToDistributedByDepartment(stationery, req_dept);
        }
        public void getJSONByItem(HttpContext context)
        {
            int deptId = Convert.ToInt32(context.Request.Form["deptId"]);

            List<MFulfillment_View> mList = new List<MFulfillment_View>();
            List<Fulfillment_View> list= new FulfillmentController().actionGetFulfillmentViewByDepartment(deptId);

            foreach (Fulfillment_View i in list)
            {
                mList.Add(new MFulfillment_View(i.id,i.department,i.stationery,i.stationery_name,i.requested_quantity,i.fulfill_quantity,i.unfulfill_quantity,(int)i.stock_control));
            }

            context.Response.Write(JsonConvert.SerializeObject(mList));
            context.Response.End();
        }
        public void actionUpdateToDisbursement(int req_dept, int stationery)
        {
            FulfillmentController fc = new FulfillmentController();

            rf=fc.actionGetFulfillmentByDepartmentAndStationery(req_dept, stationery);

            // -------------- Disbursement Table Process ----------
            disbursement = actionGetDisbursementByDepartmentAndTodayDate(req_dept);

            if (disbursement == null)
                actionCreateDisbursementTable(req_dept, getDeptRept(req_dept));

            disbursementId=actionGetDisbursementIdByDepartmentAndDate(req_dept, disbursement.distributed_date);

            // -------------- Disbursement Detail Table Process ----------
            disbursementDetail = actionGetDisbursementDetailByDepartmentAndStationery(stationery);

            if (disbursementDetail == null)
                actionCreateDisbursementDetailTable();
            else
                actionUpdateDisbursementDetailTable();

            // -------------- Update Stationery Process ----------
            new StationeryController().actionUpdateQty(rf.stationery, rf.fulfill_quantity);

            // -------------- Update StockTransaction Process ----------
            new StockTransactionController().actionCreateStockTransaction(stationery, new StationeryController().actionGetQtyInStock(stationery),
                "Disbursement", "- "+rf.fulfill_quantity.ToString());

            // -------------- Remaining Requisition Fulfillment Process ----------
            unfulfillQty = rf.requested_quantity - rf.fulfill_quantity;
            if (unfulfillQty == 0)
                fc.actionDeleteFulfillmentByObject(rf);
            else
                fc.actionUpdateFulfillmentByObject(rf, unfulfillQty);

            // -------------- Update Requisition Status Process ----------
            new RequisitionController().actionRequisitionStatusChangeToDistributedByDepartment(stationery, req_dept);
        }
        private void actionChangeAllToFulfillment()
        {
            FulfillmentController f = new FulfillmentController();

            if (chkDateTime.Checked)
            {
                DateTime dateTime = Helper.CovertToCustomDateTime(txtDate.Text, txtTime.Text, txtTimeMin.Text, ddlTime.Text);
                f.actionChangeAllToFulfillmentByDepartmentAndStationeryAndTime(deptId, stationeryId, dateTime);
            }
            else
            {
                f.actionChangeAllToFulfillmentByDepartmentAndStationery(deptId, stationeryId);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["id"].ToString() != string.Empty)
                {
                    deptId = Convert.ToInt32(Request.QueryString["id"].ToString());

                    GetDepartmentForFulfillment d = new DepartmentController().actionGetDepartmentForFulfillment(deptId);
                    ui_content_title_label.Text = "Requistions from "+d.department_name;
                    //lblDeptName.Text = d.department_name;
                    lblCollectionPoint.Text = d.name;
                    lblReptName.Text = d.representative_name;
                }

                FulfillmentController fc = new FulfillmentController();
                BindGridView();

            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //System.Threading.Thread.Sleep(2000);
            foreach (GridViewRow row in GridView1.Rows)
            {
                // protect not to fill invalid even in disable javaScript state
                // lack of check balance in code

                if (checkValidation(row))
                {
                    String txtOriginal = row.Cells[6].Text;
                    TextBox txtEditable = (TextBox)row.FindControl("TextBox1");

                    if (checkEdit(txtOriginal, txtEditable.Text))
                    {
                        deptId = Convert.ToInt32(row.Cells[2].Text);
                        stationeryId = Convert.ToInt32(row.Cells[3].Text);

                        FulfillmentController fc = new FulfillmentController();
                        fc.actionUpdateQty(deptId, stationeryId, originalQty, editableQty);

                        refreshNeed = true;
                    }
                }
            }

            showSuccess(refreshNeed, "Successfully Saved.");
        }
        private void actionChangeAllToFulfillment()
        {
            FulfillmentController f = new FulfillmentController();

            if (chkDateTime.Checked)
            {
                f.actionChangeAllToFulfillmentByDepartmentAndDateTime(deptId, Helper.CovertToCustomDateTime(txtDate.Text, txtTime.Text, txtTimeMin.Text,ddlTime.Text));
            }
            else
            {
                f.actionChangeAllToFulfillmentByDepartment(deptId);
            }
        }