Exemplo n.º 1
0
        private void BindItemName()
        {
            CurrentStockRpt obj     = new CurrentStockRpt();
            var             itmName = obj.BindActiveItemName();

            ddlItemName.DataSource     = itmName;
            ddlItemName.DataTextField  = "Item_name";
            ddlItemName.DataValueField = "Item_idno";
            ddlItemName.DataBind();
            ddlItemName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
        }
Exemplo n.º 2
0
 private void TotalRecords()
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         string UserClass = Convert.ToString(Session["Userclass"]);
         Int64  UserIdno  = 0;
         if (UserClass != "Admin")
         {
             UserIdno = Convert.ToInt64(Session["UserIdno"]);
         }
         CurrentStockRpt obj    = new CurrentStockRpt();
         Int64           YearId = Convert.ToInt64(ddlDateRange.SelectedValue);
         DataTable       list1  = obj.SelectCurrentStockReport(ApplicationFunction.ConnectionString(), Convert.ToDateTime(hidmindate.Value), 0, "", 0, YearId);
         lblTotalRecord.Text = "T. Record (s): " + Convert.ToString(list1.Rows.Count);
     }
 }
Exemplo n.º 3
0
        private void BindGrid()
        {
            CurrentStockRpt obj      = new CurrentStockRpt();
            Int64           ItemIdno = Convert.ToInt64((ddlItemName.SelectedValue) == "" ? "0" : ddlItemName.SelectedValue);
            string          serialNo = txtSerialNo.Text.Trim();
            Int64           YearID   = Convert.ToInt64(ddlDateRange.SelectedValue);
            Int64           LocIdno  = Convert.ToInt64((ddlFromCity.SelectedValue) == "" ? "0" : ddlFromCity.SelectedValue);

            dt  = obj.SelectCurrentStockReport(ApplicationFunction.ConnectionString(), Convert.ToDateTime(hidmindate.Value), ItemIdno, serialNo, LocIdno, YearID);
            obj = null;
            if (dt != null && dt.Rows.Count > 0)
            {
                DataColumn newNetTotal = new DataColumn("Qty", typeof(string));
                newNetTotal.AllowDBNull = true;
                dt.Columns.Add(newNetTotal);

                string strItemIdno = Convert.ToString(dt.Rows[0]["ItemIdno"]);

                //outer variable
                double dqty      = 0;
                double dItemRate = 0;

                // inner variable
                double ddqty      = 0;
                Double ddItemRate = 0;

                for (int k = 0; k < dt.Rows.Count; k++)
                {
                    dqty += 1;
                    dt.Rows[k]["Qty"] = 1;

                    dItemRate += Convert.ToDouble(dt.Rows[k]["RATE"].ToString());
                    // *****************************************************************************************************************************

                    if (Convert.ToString(dt.Rows[k]["ItemIdno"]) == strItemIdno)
                    {
                        //dt.Rows[k]["Qty"] = 1;
                        ddqty += 1;

                        ddItemRate += Convert.ToDouble(dt.Rows[k]["RATE"].ToString());
                    }
                    else
                    {
                        DataRow dr = dt.NewRow();
                        dr.BeginEdit();
                        dr[0] = ""; dr[1] = ""; dr[3] = "Group Total:"; dr[7] = ddItemRate.ToString("N2"); dr[8] = ddqty.ToString();

                        dt.Rows.InsertAt(dr, k);
                        dt.AcceptChanges();

                        ddqty = 0; ddItemRate = 0;

                        if (k != 0)
                        {
                            ddqty += 1;

                            ddItemRate += Convert.ToDouble(dt.Rows[k + 1]["RATE"].ToString());
                        }
                        k++;
                        strItemIdno = Convert.ToString(dt.Rows[k]["ItemIdno"]);
                    }

                    // *****************************************************************************************************************************
                }

                DataRow dr1 = dt.NewRow();
                dr1.BeginEdit();
                dr1[0] = ""; dr1[1] = ""; dr1[3] = "Group Total:"; dr1[7] = ddItemRate.ToString("N2"); dr1[8] = ddqty.ToString();


                dt.Rows.Add(dr1);

                DataRow dr2 = dt.NewRow();
                dr2.BeginEdit();
                dr2[0] = ""; dr2[1] = ""; dr2[2] = "";

                dt.Rows.Add(dr2);



                DataRow dr3 = dt.NewRow();
                dr3.BeginEdit();

                dr3[0] = ""; dr3[1] = ""; dr3[3] = "Total:"; dr3[7] = dItemRate.ToString("N2"); dr3[8] = dqty.ToString();

                dt.Rows.Add(dr3);

                grdMain.Columns.Clear();
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    BoundField bfield = new BoundField();
                    bfield.HeaderText = Convert.ToString(dt.Columns[i].ColumnName);
                    bfield.DataField  = Convert.ToString(dt.Columns[i].ColumnName);
                    grdMain.Columns.Add(bfield);
                }

                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }
                grdMain.DataSource = dt;
                grdMain.DataBind();


                grdMain.HeaderRow.Cells[0].Text      = "Item Name";
                grdMain.HeaderRow.Cells[1].Text      = "Brand";
                grdMain.HeaderRow.Cells[2].Text      = "Serial No";
                grdMain.HeaderRow.Cells[3].Text      = "Type";
                grdMain.HeaderRow.Cells[4].Text      = "Days";
                grdMain.HeaderRow.Cells[6].Text      = "Location";
                grdMain.Columns[0].HeaderStyle.Width = 140;
                grdMain.Columns[1].HeaderStyle.Width = 140;
                grdMain.Columns[2].HeaderStyle.Width = 140;
                grdMain.Columns[3].HeaderStyle.Width = 140;
                grdMain.Columns[4].HeaderStyle.Width = 140;
                grdMain.Columns[6].HeaderStyle.Width = 130;
                grdMain.Columns[7].HeaderStyle.Width = 130;
                grdMain.Columns[8].HeaderStyle.Width = 100;

                grdMain.Columns[0].HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[1].HeaderStyle.HorizontalAlign = HorizontalAlign.Left;

                grdMain.Columns[0].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[1].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[3].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[4].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[6].ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                grdMain.Columns[7].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                grdMain.Columns[8].ItemStyle.HorizontalAlign = HorizontalAlign.Right;

                grdMain.Columns[5].Visible = false;

                lblTotalRecord.Text = "T. Record : " + dqty.ToString();
                imgBtnExcel.Visible = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record : 0 ";
                imgBtnExcel.Visible = false;
            }
        }
        private void BindGrid()
        {
            CurrentStockRpt obj      = new CurrentStockRpt();
            Int64           YearIdno = Convert.ToInt64(ddlDateRange.SelectedValue);
            Int64           ItemIdno = Convert.ToInt64(ddlItemName.SelectedValue);
            Int64           LocIdno  = Convert.ToInt64(ddlFromCity.SelectedValue);
            DateTime?       dtfrom   = null;
            DateTime?       dtto     = null;


            if (string.IsNullOrEmpty(Convert.ToString(txtDate.Text)) == false)
            {
                dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtDateTO.Text)) == false)
            {
                dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTO.Text));
            }
            dt  = obj.SelectCurrentStockSummary(ApplicationFunction.ConnectionString(), YearIdno, dtfrom, dtto, LocIdno, ItemIdno);
            obj = null;
            if (dt != null && dt.Rows.Count > 0)
            {
                DataTable DTT = dt.Clone();
                DTT = dt.Copy();
                Int64 OS = 0; Int64 CL = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OS += Convert.ToInt64(DTT.Rows[i]["OS"]);
                    CL += Convert.ToInt64(DTT.Rows[i]["CL"]);
                    if (i == dt.Rows.Count - 1)
                    {
                        DataRow drr = DTT.NewRow();
                        drr["Item_Name"] = "Total";
                        drr["OS"]        = Convert.ToString(OS);
                        drr["CL"]        = Convert.ToString(CL);
                        lblOpenTot.Text  = Convert.ToString(OS);
                        lblClosTot.Text  = Convert.ToString(CL);
                        DTT.Rows.Add(drr);
                        break;
                    }
                }
                if (DTT != null && DTT.Rows.Count > 0)
                {
                    DTT.Columns[0].Caption = "Item Name";
                    DTT.Columns[1].Caption = "Opening";
                    DTT.Columns[2].Caption = "Closing";
                    DTT.AcceptChanges();
                    ViewState["Dt"] = DTT;
                }


                grdMain.DataSource = dt;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record : " + (dt.Rows.Count).ToString();
                imgBtnExcel.Visible = true;
                divpaging.Visible   = true;


                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + dt.Rows.Count.ToString();
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record : 0 ";
                imgBtnExcel.Visible = false;
                divpaging.Visible   = false;
            }
        }