예제 #1
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        dt = (DataTable)ViewState["Details"];

        if (txt_qty.Text == "")
        {
            txt_qty.Text = "0";
        }
        if (txt_price.Text == "")
        {
            txt_price.Text = "0";
        }
        if (txt_qty.Text != "" && txt_price.Text != "")
        {
            var sum_finalAmt = Convert.ToDecimal(txt_qty.Text) * Convert.ToDecimal(txt_price.Text);
            dt.Rows.Add(dd_product.SelectedItem.Text, txt_desc.Text, txt_hsn.Text, txt_qty.Text, txt_price.Text, sum_finalAmt);
            ViewState["Details"] = dt;
            GridData.DataSource  = dt;
            GridData.DataBind();

            btn_submi.Visible = true;
        }

        dd_product.SelectedIndex = 0;
        txt_desc.Text            = "";
        txt_hsn.Text             = "";
        txt_qty.Text             = "";
        txt_price.Text           = "";

        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true);
    }
예제 #2
0
        protected void GridData_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                GridViewRow gv     = GridData.SelectedRow;
                int         ItemID = int.Parse(gv.Cells[1].Text);

                var cDetail = db.ContainerDatas.Where(x => x.ID == ItemID).FirstOrDefault();
                cDetail.IsActive = false;
                db.SaveChanges();

                var     materialid = Convert.ToInt32(cDetail.MaterialID);
                var     storeid    = Convert.ToInt32(cDetail.StoreID);
                decimal Qty        = Convert.ToDecimal(cDetail.Quantity);

                DecreaseStock(materialid, storeid, Qty);
                GridData.DataBind();
            }
            catch (Exception ex)
            {
                lblAddItemErr.Text      = "Error in Item Return " + ex.InnerException.Message;
                lblAddItemErr.Visible   = true;
                lblAddItemErr.ForeColor = Color.Red;
            }
        }
        protected void btnExportstorePDF_Click(object sender, EventArgs e)
        {
            GridData.AllowPaging = false;
            GridData.DataBind();
            Response.Clear();
            Response.Buffer = true;
            Response.ClearContent();
            Response.ClearHeaders();
            Response.Charset = "";
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=CuttingListMaterialsInStore " + DateTime.Now.ToShortDateString() + ".pdf");
            GridData.GridLines             = GridLines.Horizontal;
            GridData.HeaderStyle.Font.Bold = true;
            GridData.HeaderStyle.ForeColor = System.Drawing.Color.DarkBlue;
            GridData.RenderControl(hw);
            StringReader sr         = new StringReader(sw.ToString());
            Document     pdfDoc     = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);

            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();
            GridData.AllowPaging = true;
            GridData.DataBind();
        }
        protected void LoadData()
        {
            DataAccess  obj = new DataAccess();
            CloudMaster ob  = new CloudMaster();

            ob.Id = Convert.ToInt32(Convert.ToInt32(Session["CSP1"].ToString()));
            DataTable dt = obj.SelectCloudById(ob);

            if (dt != null && dt.Rows.Count > 0)
            {
                string CloudId           = dt.Rows[0]["Id"].ToString();
                string CloudName         = dt.Rows[0]["CloudName"].ToString();
                string CloudDBServerName = dt.Rows[0]["CloudDBServerName"].ToString();
                string CloudDBUserName   = dt.Rows[0]["CloudDBUserName"].ToString();
                string CloudDBPassword   = dt.Rows[0]["CloudDBPassword"].ToString();

                string ConnectionString = "User Id = " + CloudDBUserName + "; Password = "******";Initial Catalog= " + CloudName + "; Data Source=" + CloudDBServerName;

                SqlConnection con = new SqlConnection(ConnectionString);
                con.Open();
                DataSet        dst = new DataSet();
                SqlDataAdapter dap = new SqlDataAdapter("select * from tbl_Data where RefId = " + Session["Id"].ToString() + " order by UploadedDate asc", con);
                dap.Fill(dst, "DataSetName");
                con.Close();

                GridData.DataSource = dst.Tables[0];
                GridData.DataBind();
            }
        }
        //protected void GridData_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    // Reservation ID, MaterialName,Quantity
        //    //ReservedDate,Note,UserName,
        //    //Paid,PaidAmount,ReservedStock,
        //    //StockOnHand,MaterialID,StoreID
        //    GridViewRow gv = GridData.SelectedRow;
        //    int ReservedID = Convert.ToInt32(gv.Cells[1].Text.ToString());
        //    var resmaterial = db.ReservedMaterials.Where(x => x.ID == ReservedID).FirstOrDefault();
        //    //string name = gv.Cells[2].Text;
        //    string name = resmaterial.MaterialInStock1.Material.MaterialName;

        //    //decimal QTY = Convert.ToDecimal(gv.Cells[3].Text);
        //    decimal QTY = Convert.ToDecimal(resmaterial.Quantity);
        //    string ReservationNote = resmaterial.Note;
        //    //string ReservationNote = gv.Cells[5].Text.ToString();
        //    decimal pai = Convert.ToDecimal(resmaterial.PaidAmount);

        //    //decimal pai = 0;
        //    if(gv.Cells[7].Text !=" ")
        //    {
        //        pai = Convert.ToDecimal(gv.Cells[8].Text);
        //    }


        //    //decimal reserved = Convert.ToDecimal(gv.Cells[9].Text);
        //    decimal reserved = Convert.ToDecimal(resmaterial.MaterialInStock1.ReservedStock);
        //    //decimal stock = Convert.ToDecimal(gv.Cells[10].Text);
        //    decimal stock = Convert.ToDecimal(resmaterial.MaterialInStock1.StockOnHand);
        //    //int materialid = Convert.ToInt32(gv.Cells[11].Text);
        //    int materialid = Convert.ToInt32(resmaterial.MaterialInStock1.MaterialID);
        //    //int storeid = Convert.ToInt32(gv.Cells[12].Text);
        //    int storeid = Convert.ToInt32(resmaterial.MaterialInStock1.StoreID);

        //    var item = db.MaterialInStocks.Where(x => x.MaterialID == materialid && x.StoreID == storeid ).FirstOrDefault();
        //    if (pai != 0)
        //    {
        //        decimal oldstock =  Convert.ToDecimal(item.StockOnHand);
        //        decimal newstock = oldstock + QTY;
        //        item.StockOnHand = newstock;
        //        LogSalesReservation(oldstock, newstock, item.ID, false);
        //    }

        //    item.ReservedStock = reserved - QTY;
        //    db.SaveChanges();

        //    //var materilainstock = db.MaterialInStocks.Where(x => x.MaterialID == materialid && x.StoreID == storeid).FirstOrDefault();

        //    StockLogger st = new StockLogger();
        //    st.MaterialInStock = item.ID;
        //    st.OldStock = stock;
        //    if (pai != 0 )
        //        st.NewStock = stock + reserved;
        //    else
        //        st.NewStock = stock;
        //    st.OldReservedStock = reserved;
        //    st.NewReservedStock = reserved - QTY;
        //    st.Notes = "Reservation Cancelled By " + User.Identity.Name;

        //    db.StockLoggers.Add(st);
        //    db.SaveChanges();

        //    //var resmaterial = db.ReservedMaterials.Where(x => x.MaterialInStock == item.ID && x.PaidAmount == pai && x.Quantity == QTY && x.Note == ReservationNote ).FirstOrDefault();

        //    resmaterial.IsDeleted = true;
        //    db.SaveChanges();

        //    Logger log = new Logger();
        //    log.Action ="Reservation of " + name + " in Store " + storeid.ToString() + " with Quantity "+ QTY.ToString()+" is cancelled ";
        //    log.ActionDate = DateTime.Now;
        //    log.UserName = User.Identity.Name;
        //    log.ActionType = "Cancel Reservation";
        //    db.Loggers.Add(log);
        //    db.SaveChanges();

        //    GridData.DataBind();
        //}

        protected void GridData_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow gv               = GridData.SelectedRow;
            int         ReservedID       = Convert.ToInt32(gv.Cells[1].Text.ToString());
            var         ReservedMaterial = db.ReservedMaterials.Where(x => x.ID == ReservedID).FirstOrDefault();
            string      name             = ReservedMaterial.MaterialInStock1.Material.MaterialName;
            decimal     QTY              = Convert.ToDecimal(ReservedMaterial.Quantity);
            string      ReservationNote  = ReservedMaterial.Note;
            decimal     PaidAmount       = Convert.ToDecimal(ReservedMaterial.PaidAmount);
            decimal     TotalReserved    = Convert.ToDecimal(ReservedMaterial.MaterialInStock1.ReservedStock);
            decimal     stock            = Convert.ToDecimal(ReservedMaterial.MaterialInStock1.StockOnHand);
            int         materialid       = Convert.ToInt32(ReservedMaterial.MaterialInStock1.MaterialID);
            int         storeid          = Convert.ToInt32(ReservedMaterial.MaterialInStock1.StoreID);

            var item = db.MaterialInStocks.Where(x => x.MaterialID == materialid && x.StoreID == storeid).FirstOrDefault();

            if (PaidAmount != 0)
            {
                decimal oldstock = Convert.ToDecimal(item.StockOnHand);
                decimal newstock = oldstock + QTY;
                item.StockOnHand = newstock;
                LogSalesReservation(oldstock, newstock, item.ID, false);
            }

            item.ReservedStock = TotalReserved - QTY;
            db.SaveChanges();

            StockLogger st = new StockLogger();

            st.MaterialInStock = item.ID;
            st.OldStock        = stock;
            if (PaidAmount != 0)
            {
                st.NewStock = stock + QTY;
            }
            else
            {
                st.NewStock = stock;
            }
            st.OldReservedStock = TotalReserved;
            st.NewReservedStock = TotalReserved - QTY;
            st.Notes            = "Cancel Reservation of Material ( " + item.Material.MaterialName.ToString() + " ) In Store ( " + item.Store.StoreName.ToString() + " ) Cancelled By " + User.Identity.Name;

            db.StockLoggers.Add(st);
            db.SaveChanges();

            ReservedMaterial.IsDeleted = true;
            db.SaveChanges();

            Logger log = new Logger();

            log.Action     = "Cancel Reservation of Material ( " + item.Material.MaterialName.ToString() + " ) in Store ( " + item.Store.StoreName.ToString() + " ) with Quantity " + QTY.ToString() + " is cancelled ";
            log.ActionDate = DateTime.Now;
            log.UserName   = User.Identity.Name;
            log.ActionType = "Cancel Reservation";
            db.Loggers.Add(log);
            db.SaveChanges();

            GridData.DataBind();
        }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["trn"] != "")
            {
                var Trn = Request.QueryString["trn"];

                var qry = db.SP_Get_SalesH().ToList().Where(r => r.S_TrnNo == Convert.ToInt32(Trn)).ToList();
                if (qry.Count > 0)
                {
                    txt_TrnNo.Text           = Convert.ToInt32(qry[0].S_TrnNo).ToString();
                    txt_Date.Text            = qry[0].S_Date;
                    txt_TillDate.Text        = qry[0].S_TilDate;
                    txt_Invoice.Text         = qry[0].S_Invoice;
                    txt_Client.SelectedValue = Convert.ToInt32(qry[0].S_ClientId).ToString();
                    txt_Mobile.Text          = qry[0].S_Mobile;
                    txt_Address.Text         = qry[0].S_Address;
                }

                var qry_1 = db.SP_Get_SalesL().ToList().Where(r => r.S_TrnNo == Convert.ToInt32(Trn)).ToList();
                if (qry_1.Count > 0)
                {
                    DataTable dataTable = new DataTable();
                    dataTable.Columns.Add("id");
                    dataTable.Columns.Add("Product");
                    dataTable.Columns.Add("Description");
                    dataTable.Columns.Add("HSN");
                    dataTable.Columns.Add("Qty");
                    dataTable.Columns.Add("Price");
                    dataTable.Columns.Add("UnitPrice");

                    for (int i = 0; i < qry_1.Count; i++)
                    {
                        dataTable.Rows.Add(qry_1[i].id, qry_1[i].S_Product, qry_1[i].S_Description, qry_1[i].S_HSN, qry_1[i].S_Qty, qry_1[i].S_Price, qry_1[i].S_UnitPrice);
                    }
                    GridData.DataSource = dataTable;
                    GridData.DataBind();
                }
            }

            ddClient(); dd_product_Bind();
            MaxTrn_no();
            MaxInvoice_no();

            if (ViewState["Details"] == null)
            {
                DataTable dataTable = new DataTable();
                //dataTable.Columns.Add("id");
                dataTable.Columns.Add("Product");
                dataTable.Columns.Add("Description");
                dataTable.Columns.Add("HSN");
                dataTable.Columns.Add("Qty");
                dataTable.Columns.Add("Price");
                dataTable.Columns.Add("UnitPrice");
                ViewState["Details"] = dataTable;
            }
        }
    }
        //protected void CreateIncidentButton(object sender, EventArgs e)
        //{
        //    clearTextBox();
        //    float Lat = float.Parse(LatInfo.Value);
        //    float Long = float.Parse(LngInfo.Value);
        //    //pass form variable into incidentManager
        //    int incidentID = incidentController.createIncident(reportPersonTextBox.Text, typeOfIncidentDDL.Text,
        //                        locationTextBox.Text, MainDispatchDDL.Text, contactNoTextBox.Text,
        //                        postalCodeTextBox.Text, descriptionTextBox.Text, Lat, Long);

        //    foreach (ListItem assistTypeCBL in assistTypeCheckBoxList.Items)
        //        if (assistTypeCBL.Selected == true)
        //            incidentController.addSupportType(incidentID, Convert.ToInt32(assistTypeCBL.Value));
        //    //update UI
        //    updateUIIncident();
        //    ScriptManager.RegisterStartupScript(this, GetType(), "script", "closeModal();", true);

        //    //ScriptManager.RegisterStartupScript(this, GetType(), "script", "test();", true);
        //} // end of class

        protected void sendQuery_Click(object sender, EventArgs e)
        {
            string searchQuery = searchResult.Text;
            DataTable DT = incidentController.getSearchIncident(searchQuery);
            GridData.DataSource = DT;
            GridData.DataBind();
            ViewState["DS"] = DT;
        }
예제 #8
0
    protected void GridData_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int       index = Convert.ToInt32(e.RowIndex);
        DataTable dt    = ViewState["Details"] as DataTable;

        dt.Rows[index].Delete();
        ViewState["Details"] = dt;
        GridData.DataSource  = dt;
        GridData.DataBind();
    }
 public void updateUIIncident()
 {
     DataTable DT = incidentController.getAllPendingIncident();
     DataTable DT2 = incidentController.getAllResolvedIncident();
     GridData.DataSource = DT;
     GridData.DataBind();
     GridData2.DataSource = DT2;
     GridData2.DataBind();
     ViewState["DS"] = DT;
 }
예제 #10
0
 private void ClearData()
 {
     txtitemHieght.Value     = "";
     txtItemNotes.Value      = "";
     txtItemType.Value       = "";
     txtItemWidth.Value      = "";
     txtNote.Value           = "";
     txtRequestedStock.Value = "";
     txtCurrentStock.Value   = "";
     txtStore.Value          = "";
     Itemdetails.Visible     = false;
     GridData.DataBind();
 }
        protected void GridOrderDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Itemdetails.Visible = true;
                GridViewRow gv = GridOrderDetails.SelectedRow;
                //order,material,code,name,QTy,height,Width,Type,customer,store,
                int     orderid    = int.Parse(gv.Cells[1].Text);
                int     materialid = int.Parse(gv.Cells[2].Text);
                string  code       = gv.Cells[3].Text;
                string  name       = gv.Cells[4].Text;
                decimal QTY        = decimal.Parse(gv.Cells[5].Text);
                decimal Height     = decimal.Parse(gv.Cells[6].Text);
                decimal Width      = decimal.Parse(gv.Cells[7].Text);
                string  storename  = gv.Cells[10].Text;

                string type = gv.Cells[8].Text;
                if (type == "CuttingList")
                {
                    CuttingItemReturn(materialid, name, orderid, QTY, Height, Width, storename);
                }
                else if (type == "Material")
                {
                    MaterialReturn(materialid, name, orderid, QTY, Height, Width, storename);
                }
                else if (type == "DeadMaterial")
                {
                    DeadMaterialReturn(materialid, name, orderid, QTY, Height, Width, storename);
                }


                var orderdetail = db.OrderDetails.Where(x => x.OrderID == orderid && x.MaterialID == materialid && x.Quantity == QTY).FirstOrDefault();
                orderdetail.IsActive = false;
                db.SaveChanges();


                GridOrderDetails.DataBind();
                if (GridOrderDetails.Rows.Count == 0)
                {
                    dvOrderDetails.Visible = false;
                }
                Itemdetails.Visible = false;
                GridData.DataBind();
            }
            catch (Exception ex)
            {
                LblAddNewItem.Text      = "Error in Material Return " + ex.Message;
                LblAddNewItem.Visible   = true;
                LblAddNewItem.ForeColor = Color.Red;
            }
        }
예제 #12
0
        private void RefreshGridAll()
        {
            var ret   = orderControls.GetDataByCreatedBy(CommonWeb.GetCurrentUser());
            var datas = ret.Result;

            GridData.DataSource = datas;
            GridData.DataBind();

            if (GridData.Rows.Count > 0)
            {
                GridData.UseAccessibleHeader    = true;
                GridData.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
예제 #13
0
        private void RefreshGrid()
        {
            var ret   = orderControls.GetDataByCreatedByAndComodity(CommonWeb.GetCurrentUser(), int.Parse(CmbKomoditas.SelectedValue));
            var datas = ret.Result;

            GridData.DataSource = datas;
            GridData.DataBind();

            if (GridData.Rows.Count > 0)
            {
                GridData.UseAccessibleHeader    = true;
                GridData.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
 protected void btnCancelData_Click(object sender, EventArgs e)
 {
     if (canceltype.SelectedIndex == 0)
     {
         cancelMaterialPanel.Visible = true;
         cancelCuttingPanel.Visible  = false;
         GridData.DataBind();
     }
     else if (canceltype.SelectedIndex == 1)
     {
         cancelCuttingPanel.Visible  = true;
         cancelMaterialPanel.Visible = false;
         GridCuttingReservation.DataBind();
     }
 }
예제 #15
0
        protected void btnCheckItemStock_Click(object sender, EventArgs e)
        {
            int store    = Convert.ToInt32(ToStore.SelectedValue);
            int material = Convert.ToInt32(selectitem.SelectedValue);

            var item = db.MaterialInStocks.Where(x => x.MaterialID == material && x.StoreID == store).FirstOrDefault();

            if (item == null)
            {
                LblErrCheckItem.Text      = " This Material ( " + selectitem.SelectedItem.ToString() + " ) isn't created in the store ( " + ToStore.SelectedItem.ToString() + " )";
                LblErrCheckItem.Visible   = true;
                LblErrCheckItem.ForeColor = Color.Red;
                GridData.Visible          = false;
            }
            else
            {
                Itemdetails.Visible = false;
                GridData.DataBind();
            }
        }
예제 #16
0
    protected void btn_remove_Click(object sender, EventArgs e)
    {
        Button btn = (Button)sender;

        //Get the row that contains this button
        GridViewRow gvr                  = (GridViewRow)btn.NamingContainer;
        Label       lbl_unit_price       = (Label)gvr.FindControl("lbl_unit_price");
        Label       lbl_unit_price_total = (Label)gvr.FindControl("lbl_unit_price_total");
        //Get rowindex
        int rowindex = gvr.RowIndex;

        DataTable dt = ViewState["Details"] as DataTable;

        dt.Rows[rowindex].Delete();
        ViewState["Details"] = dt;
        GridData.DataSource  = dt;
        GridData.DataBind();

        if (ViewState["Total_Amt"] != "")
        {
            decimal Total_amount = Convert.ToDecimal(ViewState["Total_Amt"]) - Convert.ToDecimal(lbl_unit_price.Text);
        }
    }
예제 #17
0
        private void AddNewitem()
        {
            try
            {
                int     storeid    = Convert.ToInt32(Store.SelectedValue);
                int     materialid = Convert.ToInt32(selectitem.SelectedValue);
                decimal QTY        = Convert.ToDecimal(txtQuantity.Value);

                ContainerData CD = new ContainerData();
                CD.MaterialID  = materialid;
                CD.StoreID     = storeid;
                CD.ContainerID = Convert.ToInt32(LblContainerID.Text);
                if (txtItemNotes.Value == null || txtItemNotes.Value == String.Empty)
                {
                    CD.Notes = "No Notes Added For item";
                }
                else
                {
                    CD.Notes = txtItemNotes.Value.ToString();
                }
                CD.IsActive = true;
                CD.Quantity = QTY;
                db.ContainerDatas.Add(CD);
                db.SaveChanges();
                GridData.DataBind();

                AddNewStock(storeid, materialid, QTY);
                txtItemNotes.Value = "";
                txtQuantity.Value  = "";
            }
            catch (Exception ex)
            {
                lblAddItemErr.Text      = "Error in item " + ex.InnerException.Message;
                lblAddItemErr.ForeColor = Color.Red;
                lblAddItemErr.Visible   = true;
            }
        }
        protected void btnExportStore_Click(object sender, EventArgs e)
        {
            GridData.AllowPaging = false;
            GridData.DataBind();
            Response.Clear();
            Response.Buffer = true;
            Response.ClearContent();
            Response.ClearHeaders();
            Response.Charset = "";
            string         FileName       = "CuttingListMaterialsInStore " + DateTime.Now.ToShortDateString() + ".xls";
            StringWriter   strwritter     = new StringWriter();
            HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
            GridData.GridLines             = GridLines.Both;
            GridData.HeaderStyle.Font.Bold = true;
            GridData.RenderControl(htmltextwrtter);
            Response.Write(strwritter.ToString());
            Response.End();
            GridData.AllowPaging = true;
            GridData.DataBind();
        }
 protected void btnGetStoreData_Click(object sender, EventArgs e)
 {
     GridData.DataBind();
 }
 protected void btnCheckItemStock_Click(object sender, EventArgs e)
 {
     Itemdetails.Visible = false;
     GridData.DataBind();
 }