Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Count != 0)
            {
                foreach (string name in Session.Keys)
                {
                    if (name == "Employee")
                    {
                        Employee myem = new Employee();
                        myem        = (Employee)Session[name];
                        Label4.Text = myem.EID.ToString();
                    }
                }
            }

            var Supbookdet = from a in myctx.Bookings
                             from b in myctx.SupervisorAssigns
                             from c in myctx.ServiceProviders
                             from d in myctx.ServiceBs

                             where a.BookingID == b.bookID && b.ServiceProviderID == c.ServiceProviderID && b.ServiceID == d.SerciveID && b.ExecID == Convert.ToInt32(Label4.Text) && a.BookingStatus == "Pending"
                             select new { c.SpPhoneNumber, a.BookingCode, a.StartTime, a.EndTime, a.ActualStartDate, a.ExpectedEndDate, name = c.SPFirstName + " " + c.SPLastName, d.ServiceName, a.BookingStatus };

            if (Supbookdet.Count() != 0)
            {
                GridView2.DataSource = Supbookdet;

                BoundField bf = (BoundField)GridView2.Columns[0];
                bf.DataField = "BookingCode";

                BoundField bf1 = (BoundField)GridView2.Columns[1];
                bf1.DataField = "ServiceName";

                BoundField bf2 = (BoundField)GridView2.Columns[2];
                bf2.DataField = "ActualStartDate";

                BoundField bf3 = (BoundField)GridView2.Columns[3];
                bf3.DataField = "ExpectedEndDate";

                BoundField bf4 = (BoundField)GridView2.Columns[4];
                bf4.DataField = "StartTime";

                BoundField bf5 = (BoundField)GridView2.Columns[5];
                bf5.DataField = "EndTime";

                BoundField bf6 = (BoundField)GridView2.Columns[6];
                bf6.DataField = "name";

                BoundField bf7 = (BoundField)GridView2.Columns[7];
                bf7.DataField = "SpPhoneNumber";

                BoundField bf8 = (BoundField)GridView2.Columns[8];
                bf8.DataField = "BookingStatus";



                GridView2.DataBind();
                //   mylist.Add(bookdet);
            }



            var bookdet = from a in myctx.Bookings
                          from b in myctx.ExeSecrataryAssigns
                          from c in myctx.ServiceProviders
                          from d in myctx.ServiceBs

                          where a.BookingID == b.bookID && b.ServiceProviderID == c.ServiceProviderID && b.ServiceID == d.SerciveID && b.ExeSecrataryID == Convert.ToInt32(Label4.Text) && a.BookingStatus == "Pending"
                          select new { c.SpPhoneNumber, a.BookingCode, a.StartTime, a.EndTime, a.ActualStartDate, a.ExpectedEndDate, name = c.SPFirstName + " " + c.SPLastName, d.ServiceName, a.BookingStatus };

            if (bookdet.Count() != 0)
            {
                GridView1.DataSource = bookdet;

                BoundField bf = (BoundField)GridView1.Columns[0];
                bf.DataField = "BookingCode";

                BoundField bf1 = (BoundField)GridView1.Columns[1];
                bf1.DataField = "ServiceName";

                BoundField bf2 = (BoundField)GridView1.Columns[2];
                bf2.DataField = "ActualStartDate";

                BoundField bf3 = (BoundField)GridView1.Columns[3];
                bf3.DataField = "ExpectedEndDate";

                BoundField bf4 = (BoundField)GridView1.Columns[4];
                bf4.DataField = "StartTime";

                BoundField bf5 = (BoundField)GridView1.Columns[5];
                bf5.DataField = "EndTime";

                BoundField bf6 = (BoundField)GridView1.Columns[6];
                bf6.DataField = "name";

                BoundField bf7 = (BoundField)GridView1.Columns[7];
                bf7.DataField = "SpPhoneNumber";

                BoundField bf8 = (BoundField)GridView1.Columns[8];
                bf8.DataField = "BookingStatus";



                GridView1.DataBind();
                //   mylist.Add(bookdet);
            }
        }
Example #2
0
 public void ShowUser()
 {
     GridView2.DataSource = bus.ShowUser();
     GridView2.DataBind();
 }
Example #3
0
        protected void btnBack_Click(object sender, EventArgs e)
        {
            string congty   = "LTY";
            string ngonngu  = Session["languege"].ToString();
            string fromdate = (string)Session["fromdate"];
            string todate   = (string)Session["todate"];
            string ynD      = (string)Session["YnDuyet"];
            string ynNoOK   = (string)Session["YnKhongDuyet"];
            string UserIDTK = (string)Session["UserIDTK"];

            if (fromdate != null && todate != null && ynD != null && ynNoOK != null && UserIDTK != null)
            {
                int YnDuyet      = int.Parse(ynD);
                int YnKhongDuyet = int.Parse(ynNoOK);
                if (UserIDTK.Trim() == "All")
                {
                    if (ngonngu == "lbl_VN")
                    {
                        DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUser(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                        if (dt.Rows.Count > 0)
                        {
                            divGrid1.Visible     = true;
                            divGrid2.Visible     = false;
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                            Session["UserIDTK"] = "All";
                        }
                    }
                    else
                    {
                        if (ngonngu == "lbl_TW")
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUserTW(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid2.Visible     = true;
                                divGrid1.Visible     = false;
                                GridView2.DataSource = dt;
                                GridView2.DataBind();
                                Session["UserIDTK"] = "All";
                            }
                        }
                        else
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUser(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid1.Visible     = true;
                                divGrid2.Visible     = false;
                                GridView1.DataSource = dt;
                                GridView1.DataBind();
                                Session["UserIDTK"] = "All";
                            }
                        }
                    }
                }
                else
                {
                    if (ngonngu == "lbl_VN")
                    {
                        DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUser(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                        if (dt.Rows.Count > 0)
                        {
                            divGrid1.Visible     = true;
                            divGrid2.Visible     = false;
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                            Session["UserIDTK"] = UserIDTK;
                        }
                    }
                    else
                    {
                        if (ngonngu == "lbl_TW")
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUserTW(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid2.Visible     = true;
                                divGrid1.Visible     = false;
                                GridView2.DataSource = dt;
                                GridView2.DataBind();
                                Session["UserIDTK"] = UserIDTK;
                            }
                        }
                        else
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUser(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid1.Visible     = true;
                                divGrid2.Visible     = false;
                                GridView1.DataSource = dt;
                                GridView1.DataBind();
                                Session["UserIDTK"] = UserIDTK;
                            }
                        }
                    }
                }
            }
        }
    public void getreports()
    {
        DataTable Report = new DataTable();

        Report.Columns.Add("vchno");
        Report.Columns.Add("VchDate");
        Report.Columns.Add("SuppinvNo");
        Report.Columns.Add("SupplierDate");
        Report.Columns.Add("SupplierName");
        Report.Columns.Add("purchaseLedger");
        Report.Columns.Add("ItemName");
        Report.Columns.Add("kgs");
        Report.Columns.Add("Addedpaise");
        Report.Columns.Add("Amount");
        Report.Columns.Add("Cortage");
        Report.Columns.Add("OtherIncome");
        Report.Columns.Add("Material");
        Report.Columns.Add("Feed");
        Report.Columns.Add("Cans");
        Report.Columns.Add("Dpu");
        Report.Columns.Add("LedgerAmount");
        Report.Columns.Add("Narration");

        string date = ddl_BillDate.Text;

        string[] p = date.Split('/', '-');
        getvald  = p[0];
        getvalm  = p[1];
        getvaly  = p[2];
        getvaldd = p[3];
        getvalmm = p[4];
        getvalyy = p[5];

        FDATE  = getvalm + "/" + getvald + "/" + getvaly;
        TODATE = getvalmm + "/" + getvaldd + "/" + getvalyy;


        SqlConnection con = new SqlConnection();

        con = DB.GetConnection();
        string sttt = "";

        sttt = "Select   vchno,REPLACE(CONVERT(VARCHAR(9), To_date, 6), ' ', '-') AS [VchDate],SuppinvNo, REPLACE(CONVERT(VARCHAR(9), To_date, 6), ' ', '-') AS [SupplierDate], SupplierName, purchaseLedger, ItemName, TotFatkg as Kgs, Addedpaise, Amount,Cortage,OtherIncome,Material,Feed,Cans,Dpu,Amount AS LedgerAmount,Narration  from   TallyExcessAmount where plant_code='" + ddl_Plantname.SelectedItem.Value + "' and frm_date='" + FDATE + "'   and to_date='" + TODATE + "'";
        SqlCommand     cmd         = new SqlCommand(sttt, con);
        SqlDataAdapter drt         = new SqlDataAdapter(cmd);
        DataTable      displaygrid = new DataTable();

        displaygrid.Rows.Clear();
        drt.Fill(displaygrid);
        if (displaygrid.Rows.Count > 0)
        {
            foreach (DataRow dr in displaygrid.Rows)
            {
                DataRow newrow = Report.NewRow();
                newrow["vchno"]          = dr["vchno"].ToString();
                newrow["VchDate"]        = dr["VchDate"].ToString();
                newrow["SuppinvNo"]      = dr["SuppinvNo"].ToString();
                newrow["SupplierDate"]   = dr["SupplierDate"].ToString();
                newrow["SupplierName"]   = dr["SupplierName"].ToString();
                newrow["purchaseLedger"] = dr["purchaseLedger"].ToString();
                newrow["ItemName"]       = dr["ItemName"].ToString();
                newrow["kgs"]            = dr["Kgs"].ToString();
                newrow["Addedpaise"]     = dr["Addedpaise"].ToString();
                newrow["Amount"]         = dr["Amount"].ToString();
                newrow["Cortage"]        = dr["Cortage"].ToString();
                newrow["OtherIncome"]    = dr["OtherIncome"].ToString();
                newrow["Material"]       = dr["Material"].ToString();
                newrow["Feed"]           = dr["Feed"].ToString();
                newrow["Cans"]           = dr["Cans"].ToString();
                newrow["Dpu"]            = dr["Dpu"].ToString();
                newrow["LedgerAmount"]   = dr["LedgerAmount"].ToString();
                newrow["Narration"]      = dr["Narration"].ToString();
                Report.Rows.Add(newrow);
            }
            Session["xportdata"] = Report;
            GridView2.DataSource = Report;
            GridView2.DataBind();
        }

        else
        {
            GridView2.DataSource = "";
            GridView2.DataBind();
        }
    }
    public void GETTALLYREPORT1()
    {
        try
        {
            con = DB.GetConnection();
            // string GETSTR = "SELECT TallyVchNo ,REPLACE(CONVERT(VARCHAR(9), VchDate, 6), ' ', '-') AS [VchDate],SupplierinvNo,SupplierinvDate,SupplierName,PurchaseLedger,ItemName,Billedqty,Rate,Amount,Cartage,otherincome,Material,Feed,CanorStock,BillAdvance,AvgFat,Avgsnf,Ts,Rts,Kgfat,KgSnf,Kgrate   FROM TallypurchaseImportAgentWsie WHERE PLANT_CODE='" + pcode + "' AND  FrmDate='" + ViewState["FD"] + "' and Todate='" + ViewState["TTODATE"] + "'  ORDER BY VchNo asc   ";
            string         GETSTR     = " Select   agent_id,(Agent_id + '-'+ Agent_Name + '-' + Plant_Name) as Suppliername,REPLACE(CONVERT(VARCHAR(9), To_date, 6), ' ', '-') AS [VchDate],Plant_Name as  Purchaseledgerofmilk,totfat_kg,Added_paise,TotAmount,Frm_date,To_date,Plant_Code from(  sELECT convert(varchar,Agent_id) as Agent_id, convert(varchar,Agent_Name) as Agent_Name,totfat_kg,Added_paise,TotAmount,Frm_date,To_date,Plant_code    FROM (Select  Agent_id,Plant_code,totfat_kg,Added_paise,TotAmount,Frm_date,To_date   from AgentExcesAmount  where plant_code='" + ddl_Plantname.SelectedItem.Value + "' and Frm_date='" + FDATE + "'   and To_date='" + TODATE + "'   ) AS  agexee  left join (Select Agent_Id as amagentid,Agent_Name,Plant_code as ampcode  from Agent_Master   where plant_code='" + ddl_Plantname.SelectedItem.Value + "') as am  on agexee.Plant_code=am.ampcode and agexee.Agent_id=am.amagentid) as leftside left join (select Plant_Code as pmcode,Plant_Name   from Plant_Master   where plant_code='" + ddl_Plantname.SelectedItem.Value + "'  group by Plant_Code,Plant_Name ) as pm  on leftside.Plant_code=pm.pmcode  ORDER BY VchNo asc   ";
            SqlCommand     cmd3       = new SqlCommand(GETSTR, con);
            SqlDataAdapter DA3        = new SqlDataAdapter(cmd3);
            DataTable      TALLREPORT = new DataTable();
            //DA3.Fill(DTG, ("Tallyimport"));
            DA3.Fill(TALLREPORT);
            DataTable tall = new DataTable();
            tall.Columns.Add("VchNo");
            tall.Columns.Add("VchDate");
            tall.Columns.Add("SupplierInvNo");
            tall.Columns.Add("SupDate");
            tall.Columns.Add("SupplierName");
            tall.Columns.Add("PurchaseLedger");
            tall.Columns.Add("ItemName");
            tall.Columns.Add("BilledQty");
            tall.Columns.Add("Rate");
            tall.Columns.Add("Amount");
            string ProcurementCortage1 = "ProcurementCortage-" + ddl_Plantname.SelectedItem.Text;
            tall.Columns.Add(ProcurementCortage1);
            string OtherIncome1 = "OtherIncome-" + ddl_Plantname.SelectedItem.Text;
            tall.Columns.Add(OtherIncome1);
            string ProcurementMaterialDebtor = "ProcurementMaterial-Debtor-" + ddl_Plantname.SelectedItem.Text;
            tall.Columns.Add(ProcurementMaterialDebtor);
            string CatteleFeedSalesAgentscs = "CattleFeedSales-Agents-" + ddl_Plantname.SelectedItem.Text;
            tall.Columns.Add(CatteleFeedSalesAgentscs);
            string getstringval = "Cans&LidsStock-" + ddl_Plantname.SelectedItem.Text;
            tall.Columns.Add(getstringval);

            string BillAdvance1;

            if ((pcode == "155") || (pcode == "156") || (pcode == "158") || (pcode == "159") || (pcode == "161") || (pcode == "162") || (pcode == "163") || (pcode == "164"))
            {
                BillAdvance1 = "Dpu Maintenance Charges-" + ddl_Plantname.SelectedItem.Text;
            }
            else
            {
                BillAdvance1 = "BillAdvance-" + ddl_Plantname.SelectedItem.Text;
            }


            tall.Columns.Add(BillAdvance1);
            tall.Columns.Add("LedgerAmount");

            tall.Columns.Add("Narration");
            foreach (DataRow drtally in TALLREPORT.Rows)
            {
                string no            = drtally[0].ToString();
                string VchDate       = drtally[1].ToString();
                string SupplierInvNo = drtally[2].ToString();
                string SupDate       = drtally[1].ToString();
                //   string SupplierName = drtally[4].ToString() + "Route Milk Bills" + ddl_Plantname.SelectedItem.Text;
                string SupplierName = drtally[4].ToString();

                string convSupplierName = SupplierName;
                string PurchaseLedger   = drtally[5].ToString();
                //    string ItemName = drtally[6].ToString();

                string ItemName;

                if ((pcode == "155") || (pcode == "156") || (pcode == "158") || (pcode == "159") || (pcode == "161") || (pcode == "162") || (pcode == "163") || (pcode == "164"))
                {
                    ItemName = "COW MILK";
                }
                else
                {
                    ItemName = "WHOLE MILK";
                }


                string BilledQty = drtally[7].ToString();

                double mmmltr = Convert.ToDouble(BilledQty);

                ViewState["lltr"] = (mmmltr / 1.03).ToString("F2");


                string Rate = drtally[8].ToString();

                double Amount             = Convert.ToDouble(drtally[9]);
                double ProcurementCortage = Convert.ToDouble(drtally[10]);
                string conamount          = (Amount - ProcurementCortage).ToString("f2");

                double CONAMTD   = Convert.ToDouble(conamount);
                double TOTAmount = CONAMTD + ProcurementCortage;


                double OtherIncomeE = Convert.ToDouble(drtally[11]);
                double ProcurementMaterialDebtorcspP = Convert.ToDouble(drtally[12]);
                double CatteleFeedSalesAgentscspP    = Convert.ToDouble(drtally[13]);
                double CansLidsStockK = Convert.ToDouble(drtally[14]);
                double BillAdvanceE   = Convert.ToDouble(drtally[15]);

                string avgfat = drtally[16].ToString();

                string Avgsnf = (drtally[17]).ToString();

                string TS = drtally[18].ToString();

                string RTS = (drtally[19]).ToString();

                string Kgfat = drtally[20].ToString();

                string KgSnf = drtally[21].ToString();

                string Kgrate = drtally[22].ToString();



                string OtherIncome = OtherIncomeE.ToString("F2");
                string ProcurementMaterialDebtorcsp = ProcurementMaterialDebtorcspP.ToString("F2");
                string CatteleFeedSalesAgentscsp    = CatteleFeedSalesAgentscspP.ToString("F2");
                string CansLidsStock = CansLidsStockK.ToString("F2");
                string BillAdvance   = BillAdvanceE.ToString("F2");


                double minusamount = Convert.ToDouble(OtherIncomeE + ProcurementMaterialDebtorcspP + CatteleFeedSalesAgentscspP + CansLidsStockK + BillAdvanceE);

                string ledamount = (TOTAmount - minusamount).ToString("f2");

                BILLDATE = drtally[4].ToString() + "(" + getvald + "-" + getvaldd + ")" + month + getvaly;
                ViewState["BILLDATE"] = BILLDATE.ToString();

                string Narration;
                //  string Narration = "Being PurChase Of MilkFrom " + ViewState["billdate"] + "TotalQty=" + BilledQty + " Kgs/ltr:" + ltr;

                if ((pcode == "155") || (pcode == "156") || (pcode == "158") || (pcode == "159") || (pcode == "161") || (pcode == "162") || (pcode == "163") || (pcode == "164"))
                {
                    double ltr = Convert.ToDouble(BilledQty);
                    string kgg = (ltr * 1.03).ToString("f2");
                    Narration = "Being PurChase Of MilkFrom " + ViewState["BILLDATE"] + "TotalQty=" + BilledQty + " Kgs/ltr:" + kgg + "A/f:" + avgfat + "A/S:" + Avgsnf + "T/S:" + TS + "R/TS:" + RTS;
                }
                else
                {
                    Narration = "Being PurChase Of MilkFrom " + ViewState["BILLDATE"] + "TotalQty=" + BilledQty + " Kgs/ltr:" + ViewState["lltr"].ToString() + "A/f:" + avgfat + "A/S:" + Avgsnf + "Kgfat:" + Kgfat + "KgSnf:" + KgSnf + "Kgrate:" + Kgrate;
                }
                //  string Narration = "Being PurChase Of MilkFrom " + ViewState["billdate"] + "TotalQty=" + BilledQty + " Kgs/ltr:" + ltr;
                tall.Rows.Add(no, VchDate, SupplierInvNo, SupDate, convSupplierName, PurchaseLedger, ItemName, BilledQty, Rate, conamount, ProcurementCortage, OtherIncome, ProcurementMaterialDebtorcsp, CatteleFeedSalesAgentscsp, CansLidsStock, BillAdvance, ledamount, Narration);
            }
            if (tall.Rows.Count > 1)
            {
                Session["xportdata"] = tall;
                GridView2.DataSource = tall;
                GridView2.DataBind();
            }
            else
            {
                GridView2.DataSource = null;
                GridView2.DataBind();
            }
        }
        catch
        {
        }
    }
 private void khoSync()
 {
     GridView2.DataSource = tool.GetData("select * from KHO");
     GridView2.DataBind();
 }
Example #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Deleted ";
            Label2.Text = "New table  ";
            string connectionString = ConfigurationManager.ConnectionStrings["conStr"].ToString();

            SqlConnection con = new SqlConnection(connectionString);

            try
            {
                con.Open();
            }
            catch (Exception)
            {
                con.Close();
                return;

                throw;
            }


            DataSet ds2     = new DataSet();
            string  sqlstr2 = "select * from Clothes_T where CPieceNumber=" + TextBox1.Text;

            SqlDataAdapter da2 = new SqlDataAdapter(sqlstr2, con);

            da2.Fill(ds2);
            GridView1.DataSource = ds2;
            GridView1.DataBind();


            SqlCommand     command;
            SqlDataAdapter adapter = new SqlDataAdapter();
            String         sql     = "Delete from Clothes_Materials_T where CPieceNumber=" + TextBox1.Text;

            command = new SqlCommand(sql, con);

            adapter.DeleteCommand = new SqlCommand(sql, con);
            adapter.DeleteCommand.ExecuteNonQuery();
            command.Dispose();

            SqlCommand     command1;
            SqlDataAdapter adapter1 = new SqlDataAdapter();
            String         sql1     = "Delete from Clothes_T where CPieceNumber=" + TextBox1.Text;

            command1 = new SqlCommand(sql1, con);

            adapter1.DeleteCommand = new SqlCommand(sql1, con);
            adapter1.DeleteCommand.ExecuteNonQuery();
            command1.Dispose();


            SqlCommand     command2;
            SqlDataAdapter adapter2 = new SqlDataAdapter();
            String         sql2     = "Delete from Piece_T where PieceNumber=" + TextBox1.Text;

            command2 = new SqlCommand(sql2, con);

            adapter2.DeleteCommand = new SqlCommand(sql2, con);
            adapter2.DeleteCommand.ExecuteNonQuery();
            command2.Dispose();


            DataSet ds3     = new DataSet();
            string  sqlstr3 = "select * from Piece_T";

            SqlDataAdapter da3 = new SqlDataAdapter(sqlstr3, con);

            da3.Fill(ds3);



            GridView2.DataSource = ds3;
            GridView2.DataBind();



            con.Close();
        }
Example #8
0
    private void Get_UsedRatechartDetailsRoutewise()
    {
        try
        {
            dtm  = DateTime.ParseExact(txt_FromDate.Text, "dd/MM/yyyy", null);
            dtm1 = DateTime.ParseExact(txt_ToDate.Text, "dd/MM/yyyy", null);
            string d1 = dtm.ToString("MM/dd/yyyy");
            string d2 = dtm1.ToString("MM/dd/yyyy");
            dt = null;
            int count = 0;

            DataTable     dts       = new DataTable();
            String        dbConnStr = ConfigurationManager.ConnectionStrings["AMPSConnectionString"].ConnectionString;
            SqlConnection conn      = null;
            using (conn = new SqlConnection(dbConnStr))
            {
                SqlCommand sqlCmd = new SqlCommand("dbo.[Get_TsRateDisplay]");
                conn.Open();
                sqlCmd.Connection  = conn;
                sqlCmd.CommandType = CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@spccode", ccode);
                sqlCmd.Parameters.AddWithValue("@sppcode", ddl_PlantName.SelectedItem.Value);
                sqlCmd.Parameters.AddWithValue("@spfrmdate", d1.Trim());
                sqlCmd.Parameters.AddWithValue("@sptodate", d2.Trim());
                sqlCmd.Parameters.AddWithValue("@spratechartmodeltype", 2);
                sqlCmd.Parameters.AddWithValue("@spcount", 0);
                SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
                da.Fill(dts);

                //
                DataTable  ksdt   = new DataTable();
                DataColumn ksdc   = null;
                DataRow    ksdr   = null;
                int        counts = dts.Rows.Count;


                // START ADDING COLUMN
                if (counts > 0)
                {
                    Image1.Visible = true;
                    Label4.Visible = true;
                    Label7.Visible = true;
                    Label7.Text    = "From :" + txt_FromDate.Text.Trim() + "  To :" + txt_ToDate.Text.Trim();
                    Label8.Visible = true;
                    Label8.Text    = ddl_PlantName.SelectedItem.Text.Trim();
                    ksdc           = new DataColumn("From");
                    ksdt.Columns.Add(ksdc);
                    ksdc = new DataColumn("To");
                    ksdt.Columns.Add(ksdc);
                    ksdc = new DataColumn("Rate");
                    ksdt.Columns.Add(ksdc);
                    ksdc = new DataColumn("Comm");
                    ksdt.Columns.Add(ksdc);
                    ksdc = new DataColumn("Bonus");
                    ksdt.Columns.Add(ksdc);
                    ksdc = new DataColumn("Smilk_kg");
                    ksdt.Columns.Add(ksdc);
                }
                // END ADDING COLUMN

                // START ADDING ROWS
                if (counts > 0)
                {
                    object id2;
                    id2 = 0;
                    int idd2 = Convert.ToInt32(id2);

                    foreach (DataRow dr2 in dts.Rows)
                    {
                        object id1;
                        id1 = dr2[0].ToString().Trim();
                        int idd1 = Convert.ToInt32(id1);
                        if (idd1 == idd2)
                        {
                        }
                        else
                        {
                            int cc = 0;
                            foreach (DataRow dr3 in dts.Rows)
                            {
                                object id3;
                                id3 = dr3[0].ToString().Trim();
                                int idd3 = Convert.ToInt32(id3);
                                if (idd1 == idd3)
                                {
                                    if (cc == 0)
                                    {
                                        ksdr     = ksdt.NewRow();
                                        ksdr[cc] = dr3[1].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[2].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[3].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[4].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[5].ToString();
                                        ksdt.Rows.Add(ksdr);

                                        ksdr     = ksdt.NewRow();
                                        cc       = 0;
                                        ksdr[cc] = dr3[6].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[7].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[8].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[9].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[10].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[11].ToString();
                                        cc++;
                                        ksdt.Rows.Add(ksdr);
                                    }
                                    else
                                    {
                                        ksdr = ksdt.NewRow();
                                        cc   = 0;

                                        ksdr[cc] = dr3[6].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[7].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[8].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[9].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[10].ToString();
                                        cc++;
                                        ksdr[cc] = dr3[11].ToString();
                                        ksdt.Rows.Add(ksdr);
                                    }
                                    idd2 = idd3;
                                }
                            }
                        }
                    }
                }
                // END ADDING ROWS

                GridView2.DataSource = ksdt;
                GridView2.DataBind();
                CallGridcolor(dts, 2);
            }
        }
        catch (Exception ex)
        {
            Lbl_Errormsg.Visible = true;
            Lbl_Errormsg.Text    = ex.ToString();
        }
    }
    /*Seleccionamos una solicitud*/
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label8.Text  = "0";
        Label11.Text = "0";
        Label12.Text = "0";
        Label13.Text = "0";
        Label14.Text = "0";
        Label15.Text = "0";
        Label16.Text = "0";
        Label17.Text = "0";
        Label18.Text = "0";
        Label19.Text = "0";
        Label20.Text = "0";
        Label21.Text = "0";
        Label22.Text = "0";
        Label23.Text = "0";
        Label24.Text = "0";
        Label25.Text = "0";
        Label26.Text = "0";
        Label27.Text = "0";
        Label28.Text = "0";
        Label29.Text = "0";
        Label30.Text = "0";
        Label31.Text = "0";
        Label32.Text = "0";
        Label33.Text = "0";
        Label34.Text = "0";
        Label35.Text = "0";
        Label36.Text = "0";
        Label37.Text = "0";
        Label38.Text = "0";
        Label39.Text = "0";

        GridView1.Visible = true;
        GridViewRow row = GridView1.SelectedRow;

        Label7.Text       = row.Cells[0].Text;
        Button4.Visible   = true;
        aceptar.Visible   = true;
        GridView2.Visible = true;
        GridView2.DataBind();

        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            if (Label8.Text == "0")
            {
                Label8.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label11.Text == "0")
            {
                Label11.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label12.Text == "0")
            {
                Label12.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label13.Text == "0")
            {
                Label13.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label14.Text == "0")
            {
                Label14.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label15.Text == "0")
            {
                Label15.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label16.Text == "0")
            {
                Label16.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label17.Text == "0")
            {
                Label17.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label18.Text == "0")
            {
                Label18.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label19.Text == "0")
            {
                Label19.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label20.Text == "0")
            {
                Label20.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label21.Text == "0")
            {
                Label21.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label22.Text == "0")
            {
                Label22.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label23.Text == "0")
            {
                Label23.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label24.Text == "0")
            {
                Label24.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label25.Text == "0")
            {
                Label25.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label26.Text == "0")
            {
                Label26.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label27.Text == "0")
            {
                Label27.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label28.Text == "0")
            {
                Label28.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label29.Text == "0")
            {
                Label29.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label30.Text == "0")
            {
                Label30.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label31.Text == "0")
            {
                Label31.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label32.Text == "0")
            {
                Label32.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label33.Text == "0")
            {
                Label33.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label34.Text == "0")
            {
                Label34.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label35.Text == "0")
            {
                Label35.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label36.Text == "0")
            {
                Label36.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label37.Text == "0")
            {
                Label37.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label38.Text == "0")
            {
                Label38.Text = GridView2.Rows[i].Cells[0].Text;
            }
            else if (Label39.Text == "0")
            {
                Label39.Text = GridView2.Rows[i].Cells[0].Text;
            }
        }

        GridView3.Visible = true;
        GridView3.DataBind();
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string account = Request["ReaderId"];
            if (account == null)
            {
                //exception-handler
                return;
            }
            //Database connection test
            string          OLMSDBConnectionString = ConfigurationManager.ConnectionStrings["OLMSDB"].ConnectionString;
            MySqlConnection OLMSDBConnection       = new MySqlConnection(OLMSDBConnectionString);
            string          selectReaderSql        = "select * from Readers where ReaderId = ?account;";

            try
            {
                OLMSDBConnection.Open();
                MySqlCommand cmd = new MySqlCommand(selectReaderSql, OLMSDBConnection);
                cmd.Parameters.AddWithValue("?account", account);
                MySqlDataReader reader = cmd.ExecuteReader();
                string          id     = "";
                while (reader.Read())
                {
                    if (reader.HasRows)
                    {
                        TextBoxEmail.Text = reader["Email"].ToString();

                        TextBoxName.Text  = reader["Name"].ToString();
                        TextBoxPhone.Text = reader["Phone"].ToString();
                        // string idNumber = reader["idNumber"].ToString();
                        //idNumber = "XXXXXXXXXXXXXX" + idNumber.Substring(idNumber.Length - 4);
                        //TextBoxIDNumber.Text = idNumber;
                        TextBoxIDNumber.Text = reader["idNumber"].ToString();
                        TextBoxPassword.Text = reader["Password"].ToString();
                        id = reader["ReaderId"].ToString();
                        break;
                    }
                }
                reader.Close();
                string selectBookSql = "select IssueTime, ReturnTime,Title, Fine " +
                                       "from  IssueRecords, BookBarcodes, Books " +
                                       "where  BookBarcodes.BookBarcode =   IssueRecords.BookBarcode and  BookBarcodes.BookId = Books.BookId " +
                                       "and IssueRecords.ReaderId = ?reader_id;";
                string selectRevervationSql = "select Books.Title, A.ReservingTime, A.ShelfId, C.StackId, A.BookBarcode from BookBarcodes as A, Books, Shelves  as C" +
                                              " where A.status = 2 and A.ReservingReaderId = ?readerid and Books.BookId = A.BookId and A.ShelfId = C.ShelfId;";
                int          totalOverdueDays = 0;
                MySqlCommand cmd2             = new MySqlCommand(selectBookSql, OLMSDBConnection);
                cmd2.Parameters.AddWithValue("?reader_id", id);
                ArrayList       issueRecords = new ArrayList();
                ArrayList       history      = new ArrayList();
                MySqlDataReader reader2      = cmd2.ExecuteReader();
                int             flag         = 1;
                while (reader2.Read())
                {
                    if (reader2.HasRows)
                    {
                        Record r = new Record();
                        r.title = (string)reader2["Title"];
                        DateTime issueTime = (DateTime)reader2["IssueTime"];
                        DateTime returnTime;
                        TimeSpan d;

                        if (reader2["ReturnTime"] is System.DBNull)
                        {
                            r.returnTime = "";
                            //获取当前时间
                            flag = 0; //未归还
                            DateTime Now = DateTime.Now;
                            d = Now.Subtract(issueTime);
                        }
                        else
                        {
                            try
                            {
                                returnTime   = (DateTime)reader2["ReturnTime"];
                                r.returnTime = returnTime.ToString();
                            }
                            catch (Exception ex)
                            {
                                returnTime   = DateTime.Now;
                                flag         = 0;
                                r.returnTime = "";
                            }
                            d = returnTime.Subtract(issueTime);
                        }
                        int delta = d.Days - 30;
                        if (delta < 0)
                        {
                            r.overdueTime = "0";
                        }
                        else
                        {
                            r.overdueTime    = delta.ToString();
                            totalOverdueDays = totalOverdueDays + delta;
                        }
                        r.issueTime = issueTime.ToString();
                        if (reader2["Fine"] is System.DBNull)
                        {
                            r.fine = "";
                        }
                        else
                        {
                            r.fine = reader2["Fine"].ToString();
                        }
                        if (flag == 1)
                        {
                            history.Add(r);
                        }
                        else
                        {
                            issueRecords.Add(r);
                        }
                    }
                }
                int    finePerDay = int.Parse(ConfigurationManager.AppSettings.Get("OverdueFinePerDay"));
                double totalFine  = totalOverdueDays * finePerDay;
                TextBoxFine.Text = totalFine.ToString();
                reader2.Close();
                MySqlCommand cmd3 = new MySqlCommand(selectRevervationSql, OLMSDBConnection);
                cmd3.Parameters.AddWithValue("?readerid", id);
                ArrayList       reversationRecords = new ArrayList();
                MySqlDataReader reader3            = cmd3.ExecuteReader();
                string          ReversationTime    = "";
                try
                {
                    ReversationTime = ConfigurationManager.AppSettings.Get("OverdueReservationDuration");
                }
                catch
                {
                    ReversationTime = "";
                }
                double ReversationTime2 = double.Parse(ReversationTime);
                while (reader3.Read())
                {
                    if (reader3.HasRows)
                    {
                        Record2 r = new Record2();
                        r.barcode = (string)reader3["BookBarcode"];
                        r.shelf   = reader3.GetString("ShelfId");
                        r.stack   = reader3.GetString("StackId");
                        r.title   = reader3.GetString("Title");
                        DateTime time    = (DateTime)reader3["ReservingTime"];
                        DateTime nowTime = DateTime.Now;
                        TimeSpan delta   = nowTime.Subtract(time);
                        double   d       = (double)delta.TotalMinutes;
                        r.time = String.Format("{0:F}", ReversationTime2 * 60 - d);
                        reversationRecords.Add(r);
                    }
                }

                GridView1.DataSource = issueRecords;
                GridView1.DataBind();
                GridView2.DataSource = reversationRecords;
                GridView2.DataBind();
                GridView3.DataSource = history;
                GridView3.DataBind();
            }
            catch (MySqlException ex)
            {
                //exception-handler
                Console.WriteLine(ex.Message);
            }
            finally
            {
                OLMSDBConnection.Close();
            }
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedItem.Text == "--Please select a pay period--")
        {
            Response.Write("<script LANGUAGE='JavaScript' >alert('Please select a Pay Period!')</script>");
            DropDownList1.Focus();
        }
        else
        {
            TextBox3.Text = "";
            string logtime = "[ " + DateTime.Now.ToLocalTime().ToString() + " ]";
            //update TechOne employe postion table :
            string T1ToComCareEmployeePosition = ConfigurationManager.AppSettings["T1ToComCareEmployeePosition"].ToString();
            // Instantiate SSIS application object
            Microsoft.SqlServer.Dts.Runtime.Application myApplication = new Microsoft.SqlServer.Dts.Runtime.Application();
            string  fileName3 = Path.Combine(Server.MapPath("~/Upload"), "LoadT1EmployePosition.dtsx");
            Package myPackage = myApplication.LoadPackage(@fileName3, null);
            myPackage.Variables["T1ServerFolder"].Value = T1ToComCareEmployeePosition;
            TextBox3.Text = TextBox3.Text + logtime + " == Starting updating TechOne employee position data...==\r\n";
            DTSExecResult myResult = myPackage.Execute();
            TextBox3.Text = TextBox3.Text + logtime + " == Updating result: " + myResult.ToString() + " == \r\n";
            TextBox3.Text = TextBox3.Text + " ********** If Updating fail, please contact System Admin to check! ********** \r\n";
            TextBox3.Text = TextBox3.Text + logtime + "  \r\n";

            // TextBox3.Text = "";
            TextBox3.Text = TextBox3.Text + logtime + " == Begin to process and analysis the timesheet data == \r\n";
            TextBox3.Text = TextBox3.Text + logtime + " == Need some time, please wait ...... == \r\n";
            System.Threading.Thread.Sleep(2000);
            ShowProcessBar();
            //execute sp to do data process
            string        connStr = ConfigurationManager.ConnectionStrings["ASADWHConnectionString"].ConnectionString;
            SqlConnection connsql = new SqlConnection(connStr);
            if (connsql.State.ToString() == "Closed")
            {
                connsql.Open();
            }
            SqlCommand Cmd = new SqlCommand("P_ComCare_Timesheet_ForT1", connsql);
            Cmd.CommandTimeout = 0;
            Cmd.CommandType    = CommandType.StoredProcedure;

            Cmd.Parameters.Add("@P_StartDay", SqlDbType.VarChar, 10).Value = DropDownList1.SelectedValue.ToString();
            // Cmd.Parameters.Add("@P_EndDay", SqlDbType.VarChar, 10).Value = "2015-08-16".ToString();
            try
            {
                Cmd.ExecuteNonQuery();
                TextBox3.Text     = TextBox3.Text + logtime + " == Data Process successfully! == \r\n";
                GridView2.Visible = true;
                GridView2.DataBind();
                //get all the records
                Int32         newRecordCount = 0;
                string        connStrall     = ConfigurationManager.ConnectionStrings["ASADWHConnectionString"].ConnectionString;
                SqlConnection connsqlall     = new SqlConnection(connStrall);
                if (connsqlall.State.ToString() == "Closed")
                {
                    connsqlall.Open();
                }
                SqlCommand Cmdall = new SqlCommand("select count(*) from CC_T1_Timesheet_ReadforExport_withno", connsqlall);
                newRecordCount = (Int32)Cmdall.ExecuteScalar();

                Label9.Visible = true;
                Label9.Text    = "Data Process successfully! There are total # " + newRecordCount.ToString() + " # lines which will be exported.";

                if (newRecordCount < 2000)
                {
                    TextBox4.Text = newRecordCount.ToString();
                }
                else
                {
                    TextBox4.Text = (newRecordCount / 5).ToString();
                }
            }
            catch (Exception eee)
            {
                TextBox3.Text  = TextBox3.Text + logtime + " == Data Process fial! [ERROR: " + eee.Message + "] == \r\n";
                Label9.Visible = true;
                Label9.Text    = "Data Process fail!";
            }
            finally
            {
                connsql.Close();
            }

            System.Threading.Thread.Sleep(500);
            ExitProcessBar();
        }
    }
Example #12
0
 protected void FormView2_ItemInserted(object sender, FormViewInsertedEventArgs e)
 {
     GridView2.DataBind();
 }
 protected void GridView2_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
 {
     GridView2.EditIndex  = -1;//không lấy giá trị cột nào hết
     GridView2.DataSource = kn.laydata("SELECT * FROM tintuc");
     GridView2.DataBind();
 }
 protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
 {
     GridView2.EditIndex  = e.NewEditIndex;
     GridView2.DataSource = kn.laydata("SELECT * from tintuc");
     GridView2.DataBind();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        SqlCommand    cmd = new SqlCommand();

        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "select * from Products";
        cmd.Connection  = con;
        SqlDataAdapter adapter = new SqlDataAdapter();

        adapter.SelectCommand = cmd;
        DataSet dataSet = new DataSet();

        try
        {
            con.Open();
            adapter.Fill(dataSet, "Products");
            var result = from item in dataSet.Tables["Products"].AsEnumerable()
                         where item.Field <int>("ProductID") == 826388
                         select new { ProductName = item.Field <string>("ProductName"), UnitPrice = item.Field <decimal>("UnitPrice"), UnitsInStock = item.Field <int>("UnitsInStock") };
            GridView1.DataSource = result;
            GridView1.DataBind();
        }
        catch (Exception)
        {
            throw new ApplicationException("Data error");
        }
        finally
        {
            con.Close();
        }

        DataTable tab = new DataTable();

        tab.Columns.Add("FileName", typeof(string));
        tab.Columns.Add("FileSize", typeof(Int64));
        tab.Columns.Add("CreationTime", typeof(DateTime));

        DataRow row = null;

        DirectoryInfo dirInfo = new DirectoryInfo(@"C:\");

        foreach (var item in dirInfo.GetFiles())
        {
            row    = tab.NewRow();
            row[0] = item.Name;
            row[1] = item.Length;
            row[2] = item.CreationTime;
            tab.Rows.Add(row);
        }

        var resultFiles = from item in tab.AsEnumerable()
                          where item.Field <Int64>("FileSize") > 10
                          select new { FileName = item.Field <string>("FileName"), FileSize = item.Field <Int64>("FileSize"), CreationTime = item.Field <DateTime>("CreationTime") };

        GridView2.DataSource = resultFiles;
        GridView2.DataBind();

        XDocument xmlFile   = XDocument.Load(@"C:\test.xml");
        var       resultXml = from item in xmlFile.Descendants("Product")
                              select new
        {
            ProductName = item.Element("ProductName").Value,
            Cost        = item.Element("Cost").Value
        };
        DataTable table = new DataTable();

        table.Columns.Add("ProductName", typeof(string));
        table.Columns.Add("Cost", typeof(int));

        DataRow RowX = null;

        foreach (var item in resultXml)
        {
            RowX    = table.NewRow();
            RowX[0] = item.ProductName;
            RowX[1] = item.Cost;
            table.Rows.Add(RowX);
        }

        var finalOut = from item in table.AsEnumerable()
                       where item.Field <int>("Cost") > 10
                       select new { ProductName = item.Field <string>("ProductName"), Cost = item.Field <int>("Cost") };

        GridView3.DataSource = finalOut;
        GridView3.DataBind();

        JoinQuery();
        StronglyTypedDataSet();
        DataViewDemo();
    }
 private void Bindgrid2()
 {
     GridView2.DataSource = lpp.Query_ProjectInfoMaterial(Convert.ToDateTime(TextBox5.Text),
                                                          Convert.ToDateTime(TextBox6.Text));
     GridView2.DataBind();
 }
Example #17
0
 private void Bindgrid2()
 {
     GridView2.DataSource = lpp.Query_StoreInfo(new Guid(mid.Text), Convert.ToDateTime(TextBox5.Text),
                                                Convert.ToDateTime(TextBox6.Text));
     GridView2.DataBind();
 }
Example #18
0
 protected void WBSSearch_Click(object sender, EventArgs e)
 {
     GridView2.DataBind();
 }
Example #19
0
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     GridView2.DataBind();
 }
Example #20
0
 protected void WBSAll_Click(object sender, EventArgs e)
 {
     SqlDataSource3.SelectCommand = "SELECT PriceID, PriceName, Complex, AnaNumber, Price, Unit, Code, PccCode, ReferenceID, ReferenceNumber FROM PriceAnalysis ";
     GridView2.DataBind();
 }
Example #21
0
    protected void BindGridView()
    {
        object orgAcctObj = Request.Params.Get("orgAcct");

        string sqlText = "select b.dba_name as shipper_name, c.dba_name as customer_name, d.dba_name as received_name,"
                         + " a.*,e.item_piece_remain as remain, e.history_date as date from warehouse_receipt a left join organization b "
                         + " on (a.elt_account_number=b.elt_account_number and a.shipper_acct = b.org_account_number) "
                         + " left join organization c "
                         + " on (a.elt_account_number=c.elt_account_number and a.customer_acct = c.org_account_number) "
                         + " left join organization d "
                         + " on (a.elt_account_number=d.elt_account_number and a.shipper_acct = d.org_account_number) "
                         + " left join warehouse_history e "
                         + " on (a.wr_num=e.wr_num ) "
                         + " where a.elt_account_number=" + elt_account_number + " AND ISNULL(a.job_status,'Pending')='Pending'"
                         + " AND a.item_piece_remain>0 and ISNULL(a.wr_num,'')<>'' and e.auto_uid=(select top 1 auto_uid from warehouse_history "
                         + " where elt_account_number=" + elt_account_number + " and wr_num=a.wr_num ";

        if (Webdatetimeedit1.Text != "")
        {
            sqlText = sqlText + " AND (history_date -1) <= '" + Webdatetimeedit1.Text + "'";
        }
        else
        {
            sqlText = sqlText + " AND history_date <= '" + DateTime.Today + "'";
        }
        sqlText = sqlText + " order by history_date desc)";

        string sqlText2 = "SELECT distinct c.dba_name as customer_name from warehouse_receipt a left join organization b "
                          + " on (a.elt_account_number=b.elt_account_number and a.shipper_acct = b.org_account_number) "
                          + " left join organization c "
                          + " on (a.elt_account_number=c.elt_account_number and a.customer_acct = c.org_account_number) "
                          + " where a.elt_account_number=" + elt_account_number + " AND ISNULL(a.job_status,'Pending')='Pending'";

        sqlText  = SQLSetFilter(sqlText);
        sqlText2 = SQLSetFilterWRIn(sqlText2);
        if (sortby == null)
        {
            if (check1.Checked == true)
            {
                if (sortway2.Text.ToString() == "")
                {
                    sortby = " customer_name";
                }
                else
                {
                    sortby = sortway2.Text.ToString();
                }
            }

            else
            {
                if (sortway2.Text.ToString() == "")
                {
                    sortby = "a.wr_num";
                }
                else
                {
                    sortby = sortway2.Text.ToString();
                }
            }
        }

        else
        {
            sortway2.Text = sortby.ToString();
            if (sortby.ToString() == sortway.Text)
            {
                sortway.Text = "";
            }
            else
            {
                sortway.Text = sortby.ToString();
            }
        }
        sqlText = sqlText + " order by " + sortby;
        if (sortby.ToString() == sortway.Text)
        {
            sqlText = sqlText + " DESC";
        }
        //clearup
        sortby = null;

        MakeDataSet("SOlist", sqlText);
        Session["currentSQL"] = sqlText;
        // label3.Text = Session["currentSQL"].ToString();
        try
        {
            if (check1.Checked == true && nextpage == null)
            {
                MakeDataSet("CustomerTable", sqlText2);
                FormatDataTable("CustomerTable");
            }
            if (ds.Tables["SOlist"].Rows.Count == 0)
            {
                no_item();
            }
            if (!check1.Checked)
            {
                GridView2.Visible = false;
                GridView1.Visible = true;
                if (ds.Tables["SOlist"].Rows.Count == 0)
                {
                    MakeEmptyGridView(GridView1, "SOlist");
                    //no_item();
                }
                else
                {
                    GridView1.PageSize   = maxRows;
                    GridView1.DataSource = ds.Tables["SOlist"].DefaultView;
                    GridView1.DataBind();
                    Get_total2();
                }
            }
            else
            {
                GridView1.Visible = false;
                GridView2.Visible = true;

                if (ds.Tables["SOlist"].Rows.Count != 0)
                {
                    if (ds.Tables["CustomerTable"].Rows.Count == 0)
                    {
                        MakeEmptyGridView(GridView2, "CustomerTable");
                    }
                    else
                    {
                        GridView2.PageSize   = maxRows;
                        GridView2.DataSource = ds.Tables["CustomerTable"].DefaultView;
                        GridView2.DataBind();
                        ds.Relations.Clear();
                        ds.Relations.Add(ds.Tables["CustomerTable"].Columns["customer_name"], ds.Tables["SOlist"].Columns["customer_name"]);
                        if (GridView2.Rows.Count != 0)
                        {
                            for (int rowIndex = 0; rowIndex < GridView2.Rows.Count; rowIndex++)
                            {
                                GridView childgv = (GridView)GridView2.Rows[rowIndex].FindControl("GridView3");
                                if (childgv != null)
                                {
                                    DataRow[] subSet = ds.Tables["CustomerTable"].Rows[rowIndex].GetChildRows(ds.Relations[0]);
                                    if (child_page_no != 0)
                                    {
                                        childgv.PageIndex = child_page_no;
                                    }

                                    DataTable dt = new DataTable();
                                    dt = ds.Tables["SOlist"].Clone();

                                    if (subSet.Length == 0)
                                    {
                                        if (rowIndex == 0)
                                        {
                                            MakeEmptyGridView2(GridView2);
                                        }
                                        else
                                        {
                                            GridView2.Rows[rowIndex].Visible = false;
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 0; i < subSet.Length; i++)
                                        {
                                            dt.Rows.Add(subSet[i].ItemArray);
                                        }

                                        childgv.DataSource = dt;
                                        childgv.DataBind();
                                        if (GridView2.Rows[0].Cells[0].Text == "No Records Found.")
                                        {
                                            GridView2.Rows[0].Visible = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    ds.Dispose();
                    Get_total2();
                }

                else
                {
                    MakeEmptyGridView(GridView2, "CustomerTable");
                }
            }
        }
        catch
        {
            Response.Write("<script>alert('Date Error. Please Check the Date and Try again'); self.close();</script>");
            //Response.End();
            Response.Write("<script>window.history.back();</script>");
        }
    }
Example #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GridView2.DataBind();
 }
    public void getagentlist()
    {
        string date = ddl_BillDate.Text;

        string[] p = date.Split('/', '-');
        if (p[1] == "01")
        {
            month = "Jan";
        }
        if (p[1] == "02")
        {
            month = "Feb";
        }
        if (p[1] == "03")
        {
            month = "Mar";
        }
        if (p[1] == "04")
        {
            month = "Apr";
        }

        if (p[1] == "05")
        {
            month = "May";
        }

        if (p[1] == "06")
        {
            month = "June";
        }

        if (p[1] == "07")
        {
            month = "July";
        }

        if (p[1] == "08")
        {
            month = "Aug";
        }

        if (p[1] == "09")
        {
            month = "Sep";
        }
        if (p[1] == "10")
        {
            month = "Oct";
        }
        if (p[1] == "11")
        {
            month = "Nov";
        }
        if (p[1] == "12")
        {
            month = "Dec";
        }
        getvald  = p[0];
        getvalm  = p[1];
        getvaly  = p[2];
        getvaldd = p[3];
        getvalmm = p[4];
        getvalyy = p[5];

        FDATE  = getvalm + "/" + getvald + "/" + getvaly;
        TODATE = getvalmm + "/" + getvaldd + "/" + getvalyy;

        ViewState["ffdate"] = FDATE;
        ViewState["ttdate"] = TODATE;
        string str = "";

        //Paymentdata
        str = " Select   agent_id,(Agent_id + '-'+ Agent_Name + '-' + Plant_Name) as Suppliername,REPLACE(CONVERT(VARCHAR(9), To_date, 6), ' ', '-') AS [VchDate],Plant_Name as  Purchaseledgerofmilk,totfat_kg,Added_paise,TotAmount,floor(TotAmount) as RTotAmount,Frm_date,To_date,Plant_Code from(  sELECT convert(varchar,Agent_id) as Agent_id, convert(varchar,Agent_Name) as Agent_Name,totfat_kg,Added_paise,TotAmount,Frm_date,To_date,Plant_code    FROM (Select  Agent_id,Plant_code,totfat_kg,Added_paise,TotAmount,Frm_date,To_date   from AgentExcesAmount  where plant_code='" + ddl_Plantname.SelectedItem.Value + "' and Frm_date='" + FDATE + "'   and To_date='" + TODATE + "'   ) AS  agexee  left join (Select Agent_Id as amagentid,Agent_Name,Plant_code as ampcode  from Paymentdata   where plant_code='" + ddl_Plantname.SelectedItem.Value + "' and Frm_date='" + FDATE + "'   and To_date='" + TODATE + "') as am  on agexee.Plant_code=am.ampcode and agexee.Agent_id=am.amagentid) as leftside left join (select Plant_Code as pmcode,Plant_Name   from Plant_Master   where plant_code='" + ddl_Plantname.SelectedItem.Value + "'  group by Plant_Code,Plant_Name ) as pm  on leftside.Plant_code=pm.pmcode";



        SqlConnection con = new SqlConnection();

        con = DB.GetConnection();
        SqlCommand     cmd        = new SqlCommand(str, con);
        SqlDataAdapter drt        = new SqlDataAdapter(cmd);
        DataTable      tallyagent = new DataTable();

        tallyagent.Rows.Clear();
        drt.Fill(tallyagent);
        checkdata();
        if (Checkstatus != 1)
        {
            foreach (DataRow tally in tallyagent.Rows)
            {
                GETTID();
                if (ddl_Plantname.SelectedItem.Text == "ARANI")
                {
                    Tallyno = "ARA";
                }
                if (ddl_Plantname.SelectedItem.Text == "KAVERIPATNAM")
                {
                    Tallyno = "KVP";
                }
                if (ddl_Plantname.SelectedItem.Text == "GUDLUR")
                {
                    Tallyno = "GUD";
                }
                if (ddl_Plantname.SelectedItem.Text == "WALAJA")
                {
                    Tallyno = "WAL";
                }
                if (ddl_Plantname.SelectedItem.Text == "V_KOTA")
                {
                    Tallyno = "VKT";
                }
                if (ddl_Plantname.SelectedItem.Text == "RCPURAM")
                {
                    Tallyno = "RCP";
                }
                if (ddl_Plantname.SelectedItem.Text == "BOMMASAMUTHIRAM")
                {
                    Tallyno = "BOMMA";
                }
                if (ddl_Plantname.SelectedItem.Text == "TARIGONDA")
                {
                    Tallyno = "TARI";
                }
                if (ddl_Plantname.SelectedItem.Text == "CSPURAM")
                {
                    Tallyno = "CSP";
                }
                if (ddl_Plantname.SelectedItem.Text == "KONDEPI")
                {
                    Tallyno = "KDP";
                }

                if (ddl_Plantname.SelectedItem.Text == "KAVALI")
                {
                    Tallyno = "KVL";
                }

                if (ddl_Plantname.SelectedItem.Text == "GUDIPALLI PADU")
                {
                    Tallyno = "GUDI";
                }
                if (ddl_Plantname.SelectedItem.Text == "KALIGIRI")
                {
                    Tallyno = "KLG";
                }



                string sno           = ViewState["maxtid"].ToString();
                string agentid       = tally[0].ToString();
                string tempsupply    = tally[1].ToString();
                string Supplierinvno = tempsupply + "(" + getvald + "-" + getvaldd + ")" + month + getvaly;
                string vchdate       = tally[2].ToString();
                string Suppliername  = tempsupply;
                string purchasemilk  = "Purchase Of Milk-" + tally[3].ToString();


                string ItemName;
                if ((pcode == "155") || (pcode == "156") || (pcode == "158") || (pcode == "159") || (pcode == "161") || (pcode == "162") || (pcode == "163") || (pcode == "164"))
                {
                    ItemName    = "COW MILK";
                    plantstatus = 1;
                    //  string narration = "Being The Svds  arani cc Procurement Milk Bill Excess Rate Variation Amount Paid For the Period   Of  Date  ,Paid through bank    svdd punapaka hdfc account no";
                }
                else
                {
                    ItemName    = "WHOLE MILK";
                    plantstatus = 2;
                }

                string totfatkg    = tally[4].ToString();
                string addedpaise  = tally[5].ToString();
                string amount      = tally[6].ToString();
                string roundamount = tally[7].ToString();

                if (plantstatus == 1)
                {
                    narration = "Being the Svds Milk Purchase Amount Excess Amount Paid Period Of:" + ddl_BillDate.Text + "Fatkg:" + totfatkg + "Rate:" + addedpaise + "TotalAmount:" + amount;
                }
                if (plantstatus == 2)
                {
                    narration = "Being the Svd Milk   Purchase Amount Excess Amount Paid Period Of:" + ddl_BillDate.Text + "Fatkg:" + totfatkg + "Rate:" + addedpaise + "TotalAmount:" + amount;
                }
                string gettp     = ViewState["maxtid"] + Tallyno + "EXRATE";
                string GETINSERT = "";
                GETINSERT = "INSERT INTO TallyExcessAmount(sno,vchno,vchdate,SuppinvNo,SupplierDate,SupplierName,purchaseLedger,ItemName,TotFatkg,Addedpaise,Amount,Cortage,OtherIncome,Material,Feed,Cans,Dpu,LedgerAmount,Narration,InsertedUser,plant_code,agent_id,Frm_date,To_date)  values                   ('" + ViewState["maxtid"] + "','" + gettp + "','" + vchdate + "','" + Supplierinvno + "','" + vchdate + "','" + Suppliername + "','" + purchasemilk + "','" + ItemName + "','" + totfatkg + "','" + addedpaise + "','" + roundamount + "','0','0','0','0','0','0','" + roundamount + "','" + narration + "','" + Session["Name"].ToString() + "','" + ddl_Plantname.SelectedItem.Value + "','" + agentid + "','" + ViewState["ffdate"].ToString() + "','" + ViewState["ttdate"].ToString() + "');";
                con       = DB.GetConnection();
                SqlCommand COMM = new SqlCommand(GETINSERT, con);
                COMM.ExecuteNonQuery();
            }
        }
        else
        {
            GridView2.DataSource = null;
            GridView2.DataBind();
        }
    }
Example #24
0
        private void CargarGrid2(string idequipo)
        {
            DBConnect  conexion  = new DBConnect();
            DataTable  datos     = conexion.SEquSol(idequipo);
            DataTable  datos3    = new DataTable();
            DataColumn columna5  = new DataColumn("Id");
            DataColumn columna6  = new DataColumn("Fecha");
            DataColumn columna7  = new DataColumn("Departamento");
            DataColumn columna8  = new DataColumn("Solicitante");
            DataColumn columna9  = new DataColumn("Estatus");
            DataColumn columna11 = new DataColumn("Tipo");

            columna5.AllowDBNull  = true;
            columna6.AllowDBNull  = true;
            columna7.AllowDBNull  = true;
            columna8.AllowDBNull  = true;
            columna9.AllowDBNull  = true;
            columna11.AllowDBNull = true;
            datos3.Columns.Add(columna5);
            datos3.Columns.Add(columna6);
            datos3.Columns.Add(columna7);
            datos3.Columns.Add(columna8);
            datos3.Columns.Add(columna11);
            datos3.Columns.Add(columna9);
            int fr = 0;

            if (datos.Rows.Count > 0)
            {
                for (fr = 0; fr < datos.Rows.Count; fr++)
                {
                    DataRow dr = datos3.NewRow();
                    dr["Id"]           = datos.Rows[fr]["Id"].ToString();
                    dr["Fecha"]        = datos.Rows[fr]["Fecha"].ToString();
                    dr["Departamento"] = datos.Rows[fr]["Departamento"].ToString();
                    dr["Solicitante"]  = datos.Rows[fr]["Solicitante"].ToString();
                    dr["Tipo"]         = datos.Rows[fr]["Tipo"].ToString();
                    dr["Estatus"]      = datos.Rows[fr]["Estatus"].ToString();
                    datos3.Rows.Add(dr);
                }
                GridView2.DataSource = datos3;
                GridView2.DataBind();
            }
            else
            {
                DataTable  datos2    = new DataTable();
                DataColumn columna1  = new DataColumn("Id");
                DataColumn columna2  = new DataColumn("Fecha");
                DataColumn columna3  = new DataColumn("Departamento");
                DataColumn columna4  = new DataColumn("Solicitante");
                DataColumn columna10 = new DataColumn("Estatus");
                DataColumn columna12 = new DataColumn("Tipo");
                columna1.AllowDBNull  = true;
                columna2.AllowDBNull  = true;
                columna3.AllowDBNull  = true;
                columna4.AllowDBNull  = true;
                columna12.AllowDBNull = true;
                columna10.AllowDBNull = true;
                datos2.Columns.Add(columna1);
                datos2.Columns.Add(columna2);
                datos2.Columns.Add(columna3);
                datos2.Columns.Add(columna4);
                datos2.Columns.Add(columna12);
                datos2.Columns.Add(columna10);
                DataRow dr = datos2.NewRow();
                dr["Id"]           = null;
                dr["Fecha"]        = null;
                dr["Departamento"] = null;
                dr["Solicitante"]  = null;
                dr["Tipo"]         = null;
                dr["Estatus"]      = null;
                datos2.Rows.Add(dr);
                GridView2.DataSource = datos2;
                GridView2.DataBind();
                int TotalColumns = GridView2.Rows[0].Cells.Count;
                GridView2.Rows[0].Cells.Clear();
                GridView2.Rows[0].Cells.Add(new TableCell());
                GridView2.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GridView2.Rows[0].Cells[0].Text       = "No existen solicitudes pendientes!!";
                ImageButton1.Visible = false;
            }
        }
Example #25
0
 protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     ShowGrid();
     GridView2.PageIndex = e.NewPageIndex;
     GridView2.DataBind();
 }
Example #26
0
 protected void gridView_PageIndexChanging2(object sender, GridViewPageEventArgs e)
 {
     CargarGrid2(TextBox1.Value);
     GridView2.PageIndex = e.NewPageIndex;
     GridView2.DataBind();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

        if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
        {
            Response.Redirect("~/index.aspx");
        }
        else
        {
            //ch1 = cbl_WeekCheck.Items[0].Selected;
            //ch2 = cbl_WeekCheck.Items[1].Selected;
            //ch3 = cbl_WeekCheck.Items[2].Selected;
            //ch4 = cbl_WeekCheck.Items[3].Selected;
            //ch5 = cbl_WeekCheck.Items[4].Selected;
            //ch6 = cbl_WeekCheck.Items[5].Selected;
            //ch7 = cbl_WeekCheck.Items[6].Selected;
            ch1 = cb_Monday.Checked;
            ch2 = cb_Tuesday.Checked;
            ch3 = cb_Wednesday.Checked;
            ch4 = cb_Thursday.Checked;
            ch5 = cb_Friday.Checked;
            ch6 = cb_Saturday.Checked;
            ch7 = cb_Sunday.Checked;

            int year_addone = System.DateTime.Now.Year + 1 - 1911;
            year.Text = "民國" + year_addone.ToString() + "年度";
            Year      = System.DateTime.Now.Year + 1;//西元明年

            wk = new Lib.WorkWeek(System.DateTime.Now.Year + 1);
            lab_LastYear.Text = "(民國" + year_addone.ToString() + "年)";
            if (wk.isSetYear == true)
            {
                lab_SetStatus.Text        = "已設定";
                lab_SetStatus.ForeColor   = Color.Blue;
                btn_SetWorkWeek.Text      = "更新";
                btn_SetWorkWeek.ForeColor = Color.Blue;
                btn_SetWorkWeek.BackColor = Color.Aquamarine;
                //cbl_WeekCheck.Items[0].Selected = wk.DicWeek[DayOfWeek.Monday];
                //cbl_WeekCheck.Items[1].Selected = wk.DicWeek[DayOfWeek.Tuesday];
                //cbl_WeekCheck.Items[2].Selected = wk.DicWeek[DayOfWeek.Wednesday];
                //cbl_WeekCheck.Items[3].Selected = wk.DicWeek[DayOfWeek.Thursday];
                //cbl_WeekCheck.Items[4].Selected = wk.DicWeek[DayOfWeek.Friday];
                //cbl_WeekCheck.Items[5].Selected = wk.DicWeek[DayOfWeek.Saturday];
                //cbl_WeekCheck.Items[6].Selected = wk.DicWeek[DayOfWeek.Sunday];
                cb_Monday.Checked    = wk.DicWeek[DayOfWeek.Monday];
                cb_Tuesday.Checked   = wk.DicWeek[DayOfWeek.Tuesday];
                cb_Wednesday.Checked = wk.DicWeek[DayOfWeek.Wednesday];
                cb_Thursday.Checked  = wk.DicWeek[DayOfWeek.Thursday];
                cb_Friday.Checked    = wk.DicWeek[DayOfWeek.Friday];
                cb_Saturday.Checked  = wk.DicWeek[DayOfWeek.Saturday];
                cb_Sunday.Checked    = wk.DicWeek[DayOfWeek.Sunday];
            }
            else
            {
                lab_SetStatus.Text        = "未設定";
                lab_SetStatus.ForeColor   = Color.Red;
                btn_SetWorkWeek.Text      = "設定";
                btn_SetWorkWeek.ForeColor = Color.Red;
                btn_SetWorkWeek.BackColor = Color.Pink;
                //cbl_WeekCheck.Items[0].Selected = false;
                //cbl_WeekCheck.Items[1].Selected = false;
                //cbl_WeekCheck.Items[2].Selected = false;
                //cbl_WeekCheck.Items[3].Selected = false;
                //cbl_WeekCheck.Items[4].Selected = false;
                //cbl_WeekCheck.Items[5].Selected = false;
                //cbl_WeekCheck.Items[6].Selected = false;
                cb_Monday.Checked    = false;
                cb_Tuesday.Checked   = false;
                cb_Wednesday.Checked = false;
                cb_Thursday.Checked  = false;
                cb_Friday.Checked    = false;
                cb_Saturday.Checked  = false;
                cb_Sunday.Checked    = false;
            }



            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Add("year", System.DateTime.Now.Year + 1);
            DataTable dt = du.getDataTableByText("select * from year where year = @year", d);
            if (dt.Rows.Count == 1)
            {
                if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                {
                    year_status.Text      = "關閉報進";
                    year_status.ForeColor = Color.Red;
                    Button1.Text          = "開放";
                    Button1.ForeColor     = Color.Green;
                    Button1.BackColor     = Color.PaleGreen;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
                else
                {
                    year_status.Text      = "開放報進";
                    year_status.ForeColor = Color.Green;
                    Button1.Text          = "關閉";
                    Button1.ForeColor     = Color.Red;
                    Button1.BackColor     = Color.Pink;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
            }


            if (IsPostBack)
            {
                //int year_addone = System.DateTime.Now.Year + 1 - 1911;
                year.Text = "民國" + year_addone.ToString() + "年度";
                d.Clear();
                d.Add("year", System.DateTime.Now.Year + 1);
                dt = du.getDataTableByText("select * from year where year = @year", d);
                if (dt.Rows.Count == 1)
                {
                    if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                    {
                        year_status.Text      = "關閉報進";
                        year_status.ForeColor = Color.Red;
                        Button1.Text          = "開放";
                        Button1.ForeColor     = Color.Green;
                        Button1.BackColor     = Color.PaleGreen;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                    else
                    {
                        year_status.Text      = "開放報進";
                        year_status.ForeColor = Color.Green;
                        Button1.Text          = "關閉";
                        Button1.ForeColor     = Color.Red;
                        Button1.BackColor     = Color.Pink;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                }
                //前端已經先關好站了,再來處理關站刪除
                if (HF_CheckDel.Value == "ok")
                {
                    HF_CheckDel.Value = "no";
                    //逐筆寄信後刪除
                    string date        = txb_InqDate.Text;
                    string center_name = DropDownList1.SelectedItem.Text;
                    string reason      = txb_Reason.Text;//關站原因
                    for (int i = 0; i < GridView2.Rows.Count; i++)
                    {
                        string sid  = GridView2.Rows[i].Cells[0].Text;
                        string id   = GridView2.Rows[i].Cells[2].Text;
                        string mail = GridView2.Rows[i].Cells[8].Text;


                        //檢查信箱欄位,有的才寄信
                        //信件文字檔案夾位置
                        string       dd = Server.MapPath(Request.ApplicationPath);
                        StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\OffStation.txt");
                        //先寄信
                        if (!string.IsNullOrEmpty(mail) & mail != "&nbsp;")//表格空字串會變成「&nbsp;」
                        {
                            MailMessage _MailToUser = new MailMessage();
                            _MailToUser.Body = _MailContentToUser.ReadToEnd();
                            _MailToUser.Body = _MailToUser.Body.Replace("%reason%", reason);
                            _MailToUser.Body = _MailToUser.Body.Replace("%id%", (id.Substring(0, id.Length - 3) + "***"));
                            _MailToUser.Body = _MailToUser.Body.Replace("%date%", date);
                            _MailToUser.Body = _MailToUser.Body.Replace("%location%", center_name);
                            Lib.SysSetting.SaveLetter(mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "臨時關站取消報名通知信", "00");
                        }

                        //再刪報名
                        du.executeNonQueryBysp("Ex107_DelResultbySid", "sid", sid);
                    }
                    Lib.SysSetting.AddLog("臨時關站", "admin", "臨時關站取消報名 , 日期:" + date + " , 地點:" + center_name, System.DateTime.Now);
                    GridView2.DataSource = null;
                    GridView2.DataBind();
                    CloseEnter();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('鑑測站已關閉,報名資料已刪除。');", true);

                    //重新整理網頁
                    //Response.Redirect(Request.FilePath);
                }
            }
        }
    }
Example #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string quickSearch = Request.QueryString["quickSearchTerm"];

            DataTable dt1 = new DataTable();

            string     strQuery = "select userImageTable.ImageFilePath, studentPersonal.firstName, studentPersonal.lastName from studentPersonal, userImageTable where userImageTable.userID=studentPersonal.userID and studentPersonal.firstName=@name";
            SqlCommand cmd      = new SqlCommand(strQuery, dbConnection);

            cmd.Parameters.AddWithValue("@name", quickSearch);
            SqlDataAdapter sda = new SqlDataAdapter();

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = dbConnection;
            try
            {
                dbConnection.Open();
                sda.SelectCommand = cmd;
                sda.Fill(dt1);


                if (dt1.Rows.Count > 0)
                {
                    GridView1.DataSource = dt1;
                    GridView1.DataBind();
                }

                else
                {
                    DataTable  dt2       = new DataTable();
                    string     strQuery2 = "select schoolName, schoolCity from schoolInfo where schoolName=@name";
                    SqlCommand cmd2      = new SqlCommand(strQuery2, dbConnection);
                    cmd2.Parameters.AddWithValue("@name", quickSearch);
                    SqlDataAdapter sda2 = new SqlDataAdapter();
                    cmd2.CommandType = CommandType.Text;
                    cmd2.Connection  = dbConnection;

                    try
                    {
                        // dbConnection.Open();
                        sda2.SelectCommand = cmd2;
                        sda2.Fill(dt2);

                        if (dt2.Rows.Count > 0)
                        {
                            GridView2.DataSource = dt2;
                            GridView2.DataBind();
                        }
                        else
                        {
                            Label1.Text = "No results Found";
                        }
                    }

                    catch (Exception ec)
                    {
                        Response.Write(ec.Message);
                    }

                    finally
                    {
                        // dbConnection.Close();
                        // sda.Dispose();
                        //dbConnection.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                dbConnection.Close();
                sda.Dispose();
                dbConnection.Dispose();
            }



            //try
            //{
            //    dbConnection.Open();
            //    string queryQuickSearch = "select userImageTable.ImageFilePath, studentPersonal.firstName, studentPersonal.lastName from studentPersonal, userImageTable where userImageTable.userID=studentPersonaal.userID and firstName=@name";
            //    //"select schoolName, schoolCity from schoolInfo where schoolName=@name";

            //    try
            //    {
            //        SqlCommand getType = new SqlCommand(queryQuickSearch, dbConnection);
            //        getType.Parameters.Add(new SqlParameter("@name", quickSearch));
            //        SqlDataReader reader = getType.ExecuteReader();
            //        while (reader.Read())
            //        {
            //            string path = reader.GetString(0);
            //        }

            //        GridView1.DataSource = getType.ExecuteReader();
            //        GridView1.
            //        GridView1.DataBind();

            //    }

            //    catch (SqlException ez)
            //    {
            //        Response.Write("<p>Error Code " + ez.Number + ": " + ez.Message + "</p>");
            //    }
            // }
            //    catch (SqlException ex)
            //    {
            //        Response.Write("<p>Error Code " + ex.Number + ": " + ex.Message + "</p>");
            //    }
            //}
        }
Example #29
0
        public void HienThiDanhSach()
        {
            string ngonngu = Session["languege"].ToString();
            string congty  = "LTY";
            int    YnDuyet;
            int    YnKhongDuyet;

            if (cbOk.Checked == true)
            {
                YnDuyet = 8;
            }
            else
            {
                YnDuyet = 9;
            }
            if (cbNoOk.Checked == true)
            {
                YnKhongDuyet = 2;
            }
            else
            {
                YnKhongDuyet = 9;
            }
            string fromdate = txtFromDate.Text.Trim();
            string todate   = txtToDate.Text.Trim();

            if (txtTimKiem.Text.Trim() == "")
            {
                if (ngonngu == "lbl_VN")
                {
                    DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUser(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                    if (dt.Rows.Count > 0)
                    {
                        divGrid1.Visible     = true;
                        divGrid2.Visible     = false;
                        GridView1.DataSource = dt;
                        GridView1.DataBind();
                        Session["UserIDTK"] = "All";
                    }
                }
                else
                {
                    if (ngonngu == "lbl_TW")
                    {
                        DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUserTW(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                        if (dt.Rows.Count > 0)
                        {
                            divGrid2.Visible     = true;
                            divGrid1.Visible     = false;
                            GridView2.DataSource = dt;
                            GridView2.DataBind();
                            Session["UserIDTK"] = "All";
                        }
                    }
                    else
                    {
                        DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoAllUser(congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                        if (dt.Rows.Count > 0)
                        {
                            divGrid1.Visible     = true;
                            divGrid2.Visible     = false;
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                            Session["UserIDTK"] = "All";
                        }
                    }
                }
            }
            else
            {
                string    UserIDTK = txtTimKiem.Text.Trim();
                DataTable dtUser   = dalUser.TimNhanVienTheoMa(congty, UserIDTK);
                if (dtUser.Rows.Count > 0)
                {
                    if (ngonngu == "lbl_VN")
                    {
                        DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUser(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                        if (dt.Rows.Count > 0)
                        {
                            divGrid1.Visible     = true;
                            divGrid2.Visible     = false;
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                            Session["UserIDTK"] = UserIDTK;
                        }
                    }
                    else
                    {
                        if (ngonngu == "lbl_TW")
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUserTW(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid2.Visible     = true;
                                divGrid1.Visible     = false;
                                GridView2.DataSource = dt;
                                GridView2.DataBind();
                                Session["UserIDTK"] = UserIDTK;
                            }
                        }
                        else
                        {
                            DataTable dt = dal.AdminTimKiemDanhSachPhieuTheoUser(UserIDTK, congty, YnDuyet, YnKhongDuyet, fromdate, todate);
                            if (dt.Rows.Count > 0)
                            {
                                divGrid1.Visible     = true;
                                divGrid2.Visible     = false;
                                GridView1.DataSource = dt;
                                GridView1.DataBind();
                                Session["UserIDTK"] = UserIDTK;
                            }
                        }
                    }
                    Session["fromdate"]     = fromdate;
                    Session["todate"]       = todate;
                    Session["YnDuyet"]      = YnDuyet.ToString();
                    Session["YnKhongDuyet"] = YnKhongDuyet.ToString();
                }
                else
                {
                    lblThongBao.Text = "UserID incorect, please try again!";
                }
            }
        }
Example #30
0
        protected void ButtonUpdateSouvenir_Click(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["conStr"].ToString();

            SqlConnection con = new SqlConnection(connectionString);

            try
            {
                con.Open();
            }
            catch (Exception)
            {
                con.Close();
                return;

                throw;
            }


            if (string.IsNullOrEmpty(TextBoxSouvenirDes.Text))
            {
                TextBoxSouvenirDes.Text = "NULL";
            }
            else
            {
                TextBoxSouvenirDes.Text = "'" + TextBoxSouvenirDes.Text + "'";
            }
            if (string.IsNullOrEmpty(TextBoxSouvenirCategory.Text))
            {
                TextBoxSouvenirCategory.Text = "NULL";
            }
            else
            {
                TextBoxSouvenirCategory.Text = "'" + TextBoxSouvenirCategory.Text + "'";
            }


            SqlCommand c1 = new SqlCommand("Update Item_T ItemName='" + TextBoxSouvenirName.Text + "', ItemDescription=" + TextBoxSouvenirDes.Text +
                                           ", Price=" + TextBoxSouvenirPrice.Text + ", TaxPercentage=" + TextBoxSouvenirTaxPer.Text +
                                           ", ISTaxNumber=" + TextBoxSouvenirSupTax.Text + " where Barcode=" + TextBoxFirstSouvenirBarcode.Text, con);

            c1.ExecuteNonQuery();

            SqlCommand c4 = new SqlCommand("Update Souvenir_T set Category=" + TextBoxSouvenirCategory.Text + " where SBarcode=" + TextBoxFirstSouvenirBarcode.Text, con);

            c4.ExecuteNonQuery();

            DataSet ds     = new DataSet();
            string  sqlstr = "select * from Item_T where Barcode=" + TextBoxFirstSouvenirBarcode.Text;

            SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);

            da.Fill(ds);
            GridView2.DataSource = ds;
            GridView2.DataBind();

            DataSet ds1     = new DataSet();
            string  sqlstr1 = "select * from Souvenir_T where SBarcode=" + TextBoxFirstSouvenirBarcode.Text;

            SqlDataAdapter da1 = new SqlDataAdapter(sqlstr1, con);

            da1.Fill(ds1);
            GridView3.DataSource = ds1;
            GridView3.DataBind();

            con.Close();

            souvenirUpdate.Visible = false;
            newSouvenir.Visible    = true;
        }