protected void btnApproveAdjust_Click(object sender, EventArgs e)
        {
            /// update adjustmentInfo  ///
            int adjust_id = Convert.ToInt32(ddlAdjustID.SelectedItem.Text);
            //int ApprovedBy_ID = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name.ToString());
            int ApprovedBy_ID = Convert.ToInt32(Session["loginUser"]);
            DateTime currentDate = DateTime.Now;
            string status = "Approve";

            AdjustmentBLL adjust_bll = new AdjustmentBLL();
            string s = adjust_bll.updateAdjustmentInfo(adjust_id, ApprovedBy_ID, currentDate, status);

            /// update Stock Item Qty ///////
            foreach (GridViewRow row in gvAdjustmentReport.Rows)
            {
                string item_code = row.Cells[1].Text;
                int qty = Convert.ToInt32(row.Cells[2].Text);

                StockItemBLL stockItem_bll = new StockItemBLL();
                string updateStock_msg = stockItem_bll.updateStockQty(item_code, qty);

                string desc = stockItem_bll.GetItemDescription(item_code);
                StockHistoryBLL stockbll = new StockHistoryBLL();
                string history_msg = stockbll.AddStockHistoryForAdjustment(item_code, desc, qty, currentDate, ApprovedBy_ID);
                lblUpdateMsg.Text = updateStock_msg + history_msg;
            }
        }
        protected void btnCheck_Click(object sender, EventArgs e)
        {
            StockItemBLL stockBll = new StockItemBLL();
            int cat_Id = Convert.ToInt32(ddlCateogryList.SelectedItem.Value);
            var item_list = stockBll.GetCategoryList_ByItem(cat_Id);

            gvItemInfoList.DataSource = item_list;
            gvItemInfoList.DataBind();
        }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     StockItemBLL stock_bll = new StockItemBLL();
     //Stock_Item item = new Stock_Item();
     string tem_Code = Session["item_code"].ToString();
     int categoryID = Convert.ToInt32(txtCategory.Text);
     string description = txtDesc.Text;
     int reorder_Level = Convert.ToInt32(txtReorder.Text);
     int reorder_Qty = Convert.ToInt32(txtReorderQty.Text);
     string unit_of_Measure = txtUnit.Text;
     int qty = Convert.ToInt32(txtQuantity.Text);
     string update_msg = stock_bll.UpdateStockItem(tem_Code, categoryID, description, reorder_Level, reorder_Qty, unit_of_Measure, qty);
     lblmsg.Text = update_msg;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CategoryBLL category_bll = new CategoryBLL();
            string category_name = txtCategory.Text;
            int cat_id = category_bll.AddNewCategory(category_name);

            StockItemBLL stockBll = new StockItemBLL();
            string item_Code = txtItemNo.Text;
            // int categoryID = Convert.ToInt32(txtCategory.Text);
            string description = txtDesc.Text;
            int reorder_Level = Convert.ToInt32(txtReorderLevel.Text);
            int reorder_Qty = Convert.ToInt32(txtReorderQty.Text);
            string unit = ddlUnit.SelectedItem.Text;
            int qty = Convert.ToInt32(txtQuantity.Text);

            string add_info = stockBll.AddNewStockItem(item_Code, cat_id, description, reorder_Level, reorder_Qty, unit, qty);
            lblmsg.Text = add_info;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            adjustment_View adjust_view = new adjustment_View();
            AdjustmentBLL adjustbll = new AdjustmentBLL();

            //int adjustBy_Id = 1005;
              // int loginUserId = 1002;// current login User who will make Adjustment Report
            int loginUserId = Convert.ToInt32(Session["loginUser"]);
            DateTime adjustDate = DateTime.Now;
            //DateTime adjustDate = DateTime.Today;

            int itemPrice = Convert.ToInt32(ddlPrice.SelectedItem.Value);

            //int approvedBy = null;
            //DateTime approveDate = null;
            //string approveStatus = null;
            double total_price = 0;
            foreach (GridViewRow row in gvAdjustList.Rows)
            {

                string item_code = row.Cells[1].Text;
                int qty = Convert.ToInt32(row.Cells[2].Text);

                StockItemBLL itemBll = new StockItemBLL();
                double price = itemBll.GetItemPrice(item_code);

                total_price = total_price + (price * qty);

                /********* Don't delete lbl testing line **********/
                //lblPrice.Text = price.ToString();
                //lblTotalPrice.Text = total_price.ToString(); // don't delete

            }
            string authorizedBy = null;

            if (total_price <= 250)
            {
                authorizedBy = "Supervisor";
            }
            else
            {
                authorizedBy = "Manager";
            }
            int adjustid = adjustbll.addAdjustment(loginUserId, adjustDate, authorizedBy);

            foreach (GridViewRow row in gvAdjustList.Rows)
            {
                string item_code = row.Cells[1].Text;
                int qty = Convert.ToInt32(row.Cells[2].Text);
                string reason = row.Cells[3].Text;
                string status = row.Cells[4].Text;

                AdjustmentDetailsBLL adjust_details_bll = new AdjustmentDetailsBLL();
                int adjustment_details_Id = adjust_details_bll.addAdjustmentDetails(adjustid, item_code, qty, reason, status);

            }

            Employee emp_bll = new Employee();
            //int loginUserId = 1002;
            string email_body = "Adjustment Report is submitted to Supervier or Manager by StoreClerk";
            string email_subj = "Issue Adjustment Report";
            string email_msg = SendEmailNotification(loginUserId, email_body, email_subj, authorizedBy);

            lblSubmitMsg.Text = "Adjustment Report Submittion is successful. " + email_msg;
        }
 private void FillStockItemList()
 {
     StockItemBLL stockItembll = new StockItemBLL();
     Stock_Item stockitem = new Stock_Item();
     var itemList = stockItembll.GetStockItem();
     ddlItemName.DataSource = itemList;
     ddlItemName.DataTextField = "Description";
     ddlItemName.DataValueField = "Item_Code";
     ddlItemName.DataBind();
 }
        protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            CategoryBLL category_bll = new CategoryBLL();
            StockItemBLL stock_bll = new StockItemBLL();

            string category_name = ddlCategory.SelectedItem.Text;
            int category_id = category_bll.GetCategoryId(category_name);

            /*****Testing for Category ID value
            //lblCategoryValue.Text = category_id.ToString(); */
            var item_list = stock_bll.GetCategoryList_ByItem(category_id);

            ddlItemName.DataSource = item_list;
            ddlItemName.DataTextField = "Description";
            ddlItemName.DataValueField = "Item_Code";
            ddlItemName.DataBind();
        }
        void ddlItem_DataBind(int categoryid)
        {
            StockItemBLL itembll = new StockItemBLL();

            var itemlist = itembll.GetStockItemByCategorID(categoryid);
            if (itemlist.Count != 0)
            {
                ddlItem.DataTextField = "Description";
                ddlItem.DataValueField = "Item_Code";
                ddlItem.DataSource = itemlist;
                ddlItem.DataBind();
            }
            else
            {
                ddlItem.Items.Clear();
                ddlItem.Items.Insert(0, "No Items for this Category");
            }
        }
        /*
        public DataSet myDataSet
        {
            get
            {
                return ViewState["myDataSet"] != null ? (DataSet)ViewState["myDataSet"] : null;
            }
            set
            {
                ViewState["myDataSet"] = value;
            }
        }
           * */
        protected void gvItemInfoList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            StockItemBLL stockBll = new StockItemBLL();
            int index = Convert.ToInt32(e.RowIndex);
            string itemCode = gvItemInfoList.Rows[index].Cells[2].Text;
            string delete_msg = stockBll.DeleteStockItem(itemCode);
            lblmsg.Text = delete_msg;
            gvItemInfoList.EditIndex = -1;

            int cat_Id = Convert.ToInt32(ddlCateogryList.SelectedItem.Value);
            var item_list = stockBll.GetCategoryList_ByItem(cat_Id);

            gvItemInfoList.DataSource = item_list;
            gvItemInfoList.DataBind();
            //gvItemInfoList.DataSource = gvItemInfoList;
            gvItemInfoList.DataBind();
        }