Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Employ_Sno"] != null)
        {
            string sno = Session["Employ_Sno"].ToString();
            cmd = new SqlCommand("update employe_details set loginflag=@log where sno=@sno");
            cmd.Parameters.Add("@log", "0");
            cmd.Parameters.Add("@sno", sno);
            vdm.Update(cmd);

            DateTime ServerDateCurrentdate = SalesDBManager.GetTime(vdm.conn);
            cmd = new SqlCommand("Select max(sno) as transno from logininfo where UserId=@userid AND UserName=@UserName");
            cmd.Parameters.Add("@userid", Session["Employ_Sno"]);
            cmd.Parameters.Add("@UserName", Session["UserName"]);
            DataTable dttime = vdm.SelectQuery(cmd).Tables[0];
            if (dttime.Rows.Count > 0)
            {
                string transno = dttime.Rows[0]["transno"].ToString();
                cmd = new SqlCommand("UPDATE logininfo set logouttime=@logouttime where sno=@sno");
                cmd.Parameters.Add("@logouttime", ServerDateCurrentdate);
                cmd.Parameters.Add("@sno", transno);
                vdm.Update(cmd);
            }
        }
        else
        {
            cmd = new SqlCommand("update employe_details set loginflag=@log");
            cmd.Parameters.Add("@log", "0");
            vdm.Update(cmd);
        }
        Session.Clear();
        Session.RemoveAll();
        Session.Abandon();
        Response.Cookies["UserName"].Expires   = DateTime.Now.AddDays(-1);
        Response.Cookies["Employ_Sno"].Expires = DateTime.Now.AddDays(-1);
        Response.Redirect("Default.aspx");
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime ServerDateCurrentdate = SalesDBManager.GetTime(vdm.conn);

        //cmd = new SqlCommand("Select max(sno) as transno from logininfo where UserId=@userid");
        //cmd.Parameters.Add("@userid", Session["Employ_Sno"]);
        //cmd.Parameters.Add("@UserName", Session["UserName"]);
        if (Session["Employ_Sno"] != "" || Session["Employ_Sno"] != null || Session["Employ_Sno"] != "undefined")
        {
            string sno = Session["Employ_Sno"].ToString();
            cmd = new SqlCommand("update employee_erp set loginstatus=@log where sno=@sno");
            cmd.Parameters.Add("@log", "0");
            cmd.Parameters.Add("@sno", sno);
            vdm.Update(cmd);

            cmd = new SqlCommand("Select max(sno) as transno from logininfo where UserId=@userid");
            cmd.Parameters.Add("@userid", sno);
            DataTable dttime = vdm.SelectQuery(cmd).Tables[0];
            if (dttime.Rows.Count > 0)
            {
                string transno = dttime.Rows[0]["transno"].ToString();
                cmd = new SqlCommand("UPDATE logininfo set logouttime=@logouttime,status=@status where sno=@sno");
                cmd.Parameters.Add("@logouttime", ServerDateCurrentdate);
                cmd.Parameters.Add("@status", "0");
                cmd.Parameters.Add("@sno", transno);
                vdm.Update(cmd);
            }
        }
        ExpireAllCookies();
        Session.Clear();
        Session.RemoveAll();
        Session.Abandon();
        //window.localStorage.clear();
        //ClearCache();
        //clearchachelocalall();
        Response.Redirect("login.aspx");
    }
Ejemplo n.º 3
0
    protected void btn_finalizeclick(object sender, EventArgs e)
    {
        DateTime  ServerDateCurrentdate = SalesDBManager.GetTime(vdm.conn);
        DataTable dtdetails             = (DataTable)Session["finalize"];

        if (dtdetails.Rows.Count > 0)
        {
            DateTime fromdate  = DateTime.Now;
            string[] datestrig = dtp_FromDate.Text.Split(' ');
            if (datestrig.Length > 1)
            {
                if (datestrig[0].Split('-').Length > 0)
                {
                    string[] dates = datestrig[0].Split('-');
                    string[] times = datestrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }

            string   date = fromdate.ToString("dd/MM/yyyy");
            string[] data = date.Split('/');

            string month      = data[1].ToString();
            string year       = data[2].ToString();
            string mainbranch = Session["Branch_ID"].ToString();
            foreach (DataRow dr in dtdetails.Rows)
            {
                string productid     = dr["ProductId"].ToString();
                string packingcharge = dr["RATE PER LTR"].ToString();
                cmd = new SqlCommand("Update packingcharges set rateperltr=@rateperltr where productid=@pid and month=@month and year=@yr and branchid=@bid");
                cmd.Parameters.Add("@month", month);
                cmd.Parameters.Add("@yr", year);
                cmd.Parameters.Add("@pid", productid);
                cmd.Parameters.Add("@rateperltr", packingcharge);
                cmd.Parameters.Add("@bid", mainbranch);
                if (vdm.Update(cmd) == 0)
                {
                    cmd = new SqlCommand("INSERT INTO packingcharges(productid, rateperltr, month, year, branchid, doe) values (@productid, @rate, @mnth, @year, @branchid, @doe)");
                    cmd.Parameters.Add("@mnth", month);
                    cmd.Parameters.Add("@year", year);
                    cmd.Parameters.Add("@productid", productid);
                    cmd.Parameters.Add("@rate", packingcharge);
                    cmd.Parameters.Add("@branchid", mainbranch);
                    cmd.Parameters.Add("@doe", ServerDateCurrentdate);
                    vdm.insert(cmd);
                }
            }
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            SalesDBManager nvdm          = new SalesDBManager();
            DataTable      dtconsumption = (DataTable)Session["xportdata"];
            DateTime       CreateDate    = SalesDBManager.GetTime(nvdm.conn);
            string         createdby     = Session["Employ_Sno"].ToString();
            if (dtconsumption.Rows.Count > 0)
            {
                foreach (DataRow dr in dtconsumption.Rows)
                {
                    string   date       = dr["Invoice Date"].ToString();
                    DateTime dt         = Convert.ToDateTime(date);
                    string   qty        = dr["Qty"].ToString();
                    string   vcehicleno = dr["Customer Name"].ToString();
                    string   Rate       = dr["Rate"].ToString();
                    string   pid        = "2285";
                    if (Convert.ToDouble(qty) > 0)
                    {
                        sqlcmd = new SqlCommand("Insert into diesel_consumptiondetails (productid, qty, doe, vehicleno, dieselcost, createdby, createddate, branchid, categoryid, subcategoryid) values (@productid, @qty, @doe, @vehicleno, @dieselcost, @createdby, @createddate,@branchid, @catid, @subcatid)");
                        sqlcmd.Parameters.Add("@productid", pid);
                        sqlcmd.Parameters.Add("@qty", qty);
                        sqlcmd.Parameters.Add("@doe", dt);
                        sqlcmd.Parameters.Add("@vehicleno", vcehicleno);
                        sqlcmd.Parameters.Add("@createdby", createdby);
                        sqlcmd.Parameters.Add("@createddate", CreateDate);
                        sqlcmd.Parameters.Add("@dieselcost", Rate);
                        sqlcmd.Parameters.Add("@branchid", "2");
                        sqlcmd.Parameters.Add("@catid", "8");
                        sqlcmd.Parameters.Add("@subcatid", "37");
                        nvdm.insert(sqlcmd);

                        sqlcmd = new SqlCommand("update productmoniter set qty=qty-@qty where productid='2285' AND branchid=@branchid");
                        sqlcmd.Parameters.Add("@branchid", "2");
                        sqlcmd.Parameters.Add("@qty", qty);
                        nvdm.Update(sqlcmd);
                    }
                }
                lblmsg.Text = "Successfuly Saved";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 5
0
 protected void btnSubmitt_Click(object sender, EventArgs e)
 {
     try
     {
         if (Session["Employ_Sno"] != null)
         {
             lblError.Text = "";
             UserName      = Session["Employ_Sno"].ToString();
             vdm           = new SalesDBManager();
             cmd           = new SqlCommand("SELECT Passward FROM employee_erp WHERE Sno = @Sno");
             cmd.Parameters.Add("@Sno", UserName);
             DataTable dt = vdm.SelectQuery(cmd).Tables[0];
             if (dt.Rows.Count > 0)
             {
                 if (txtNewPassWord.Text == txtConformPassWord.Text)
                 {
                     txtNewPassWord.Text = txtConformPassWord.Text;
                     cmd = new SqlCommand("Update employee_erp set Passward=@Password where Sno=@Sno ");
                     cmd.Parameters.Add("@Sno", UserName);
                     cmd.Parameters.Add("@Password", txtNewPassWord.Text.Trim());
                     vdm.Update(cmd);
                     lblMessage.Text = "Your Password has been Changed successfully";
                     Response.Redirect("Login.aspx", false);
                 }
                 else
                 {
                     lblError.Text = "Conform password not match";
                 }
             }
             else
             {
                 lblError.Text = "Entered username is incorrect";
             }
         }
         else
         {
             Response.Redirect("Login.aspx", false);
         }
     }
     catch (Exception ex)
     {
         lblError.Text = "Password Changed Failed";
     }
 }
Ejemplo n.º 6
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            vdm = new SalesDBManager();
            string dieselqty = Session["quantity"].ToString();
            string branchid  = Session["Po_BranchID"].ToString();
            double qty       = Convert.ToDouble(dieselqty);
            cmd = new SqlCommand("update productmoniter set qty=qty-@qty where productid='2285' AND branchid=@branchid");
            cmd.Parameters.Add("@branchid", branchid);
            cmd.Parameters.Add("@qty", qty);
            vdm.Update(cmd);

            cmd = new SqlCommand("insert into diesellogs(Date,Route,VehicleNo,VehicleType,DieselFilled,DriverName,LoadType,StartReading,PumpReading,Token) values ()");

            lblmsg.Text = "Successfuly Updated";
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = (DataTable)Session["btnImport"];
         int       i  = 1;
         foreach (DataRow dr in dt.Rows)
         {
             vdm = new SalesDBManager();
             string sup_name = dr["Software Name"].ToString();
             cmd = new SqlCommand("update suppliersdetails set suppliercode=@sapcode,tsuppliername=@tallyname where name=@sup_name");
             cmd.Parameters.Add("@sapcode", dr["Sap Code"].ToString());
             cmd.Parameters.Add("@sup_name", sup_name);
             cmd.Parameters.Add("@tallyname", dr["Tally Name"].ToString());
             vdm.Update(cmd);
             i++;
         }
         lblmsg.Text = i + "Records updated successfully";
     }
     catch
     {
     }
 }
    protected void btn_WIDB_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)Session["dtImport"];
            int       i  = 1;
            foreach (DataRow dr in dt.Rows)
            {
                vdm = new SalesDBManager();
                string itemcode = dr["icode"].ToString();
                string scc      = dr["scode"].ToString();
                string pcode    = dr["mcode"].ToString();
                cmd = new SqlCommand(" UPDATE productmaster SET  productcode = @pcode, sub_cat_code = @scc where itemcode =@itemcode");
                cmd.Parameters.Add("@itemcode", itemcode);
                cmd.Parameters.Add("@pcode", pcode);
                cmd.Parameters.Add("@scc", scc);
                vdm.Update(cmd);

                //cmd = new SqlCommand("update productmoniter set qty=@qty, price=@price where ProductId=@ProductId");
                //cmd.Parameters.Add("@qty", ClosingQty);
                //cmd.Parameters.Add("@price", ClosingPrice);
                //cmd.Parameters.Add("@ProductId", ProductId);
                //vdm.Update(cmd);
                //cmd = new SqlCommand("update productmaster set availablestores=@qty, price=@price where ProductId=@ProductId");
                //cmd.Parameters.Add("@qty", ClosingQty);
                //cmd.Parameters.Add("@price", ClosingPrice);
                //cmd.Parameters.Add("@ProductId", ProductId);
                //vdm.Update(cmd);
                i++;
            }
            lblmsg.Text = i + "Records updated successfully";
        }
        catch
        {
        }
    }
Ejemplo n.º 9
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dtmiss = new DataTable();
            dtmiss.Columns.Add("sno");
            dtmiss.Columns.Add("Itemcode");
            dtmiss.Columns.Add("productname");
            DataTable dt    = (DataTable)Session["btnImport"];
            int       count = dt.Rows.Count;
            int       i     = 1;
            foreach (DataRow dr in dt.Rows)
            {
                vdm = new SalesDBManager();
                //////string itemname = dr["MATERIAL"].ToString();
                //////string catname = dr["Category Name"].ToString();
                //////string subcatname = dr["Sub Category Name"].ToString();
                //////string UOM = dr["UOM"].ToString();
                //////string minstock = dr["MinStock"].ToString();
                //////string maxstock = dr["MaxStock"].ToString();
                //////string qty = dr["Avilable Stores"].ToString();
                //////string price = dr["Price"].ToString();
                //////string amt = dr["AMOUNT"].ToString();
                //////string uomid = "";


                //////cmd = new SqlCommand("insert into categorymaster(category, createdby, status,branchid) values(@productid,@qty,@price,@entryby,@doe,@branchid)");
                //////cmd.Parameters.Add("@category", catname);
                //////cmd.Parameters.Add("@status", "True");
                //////cmd.Parameters.Add("@createdby", "03/26/2018");
                //////cmd.Parameters.Add("@branchid", "1064");
                //////vdm.insert(cmd);

                //////cmd = new SqlCommand("SELECT MAX(categoryid) as categoryid FROM categorymaster");
                //////DataTable dtcategory = vdm.SelectQuery(cmd).Tables[0];
                //////string categoryid = dtcategory.Rows[0]["categoryid"].ToString();

                //////cmd = new SqlCommand("insert into subcategorymaster(categoryid,subcategoryname,status,branchid) values (@categoryid, @subcategoryname, @scstatus, @scbranchid )");
                //////cmd.Parameters.Add("@categoryid", categoryid);
                //////cmd.Parameters.Add("@subcategoryname", subcatname);
                //////cmd.Parameters.Add("@scstatus", "True");
                //////cmd.Parameters.Add("@scbranchid", "1064");
                //////vdm.insert(cmd);

                //////cmd = new SqlCommand("select MAX(subcategoryid) as subcategoryid from subcategorymaster");
                //////DataTable dtsubcategory = vdm.SelectQuery(cmd).Tables[0];
                //////string subcategoryid = dtsubcategory.Rows[0]["subcategoryid"].ToString();

                //////cmd = new SqlCommand("insert into productmaster(subcategoryid, productname, sku, price, availablestores, uim, categoryid, branchid, itemcode) values ()");
                //////cmd.Parameters.Add("@productname", itemname);
                //////cmd.Parameters.Add("@subcategoryid", subcategoryid);
                //////cmd.Parameters.Add("@sku", "productid");
                //////cmd.Parameters.Add("@price", price);
                //////cmd.Parameters.Add("@availablestores", qty);
                //////cmd.Parameters.Add("@uim", UOM);
                //////cmd.Parameters.Add("@categoryid", categoryid);
                //////cmd.Parameters.Add("@itemcode", itemname);
                //////cmd.Parameters.Add("@branchid", "1064");
                //////vdm.insert(cmd);

                //////cmd = new SqlCommand("select MAX(productid) as productid from productmaster");
                //////DataTable dtproduct = vdm.SelectQuery(cmd).Tables[0];
                //////string productid = dtsubcategory.Rows[0]["productid"].ToString();

                //////cmd = new SqlCommand("insert into productmoniter( productid, qty, price, branchid, minstock, maxstock) values (@productid, @mqty, @mprice,@mbranchid,@minstock,@maxstock)");
                //////cmd.Parameters.Add("@productid", productid);
                //////cmd.Parameters.Add("@mqty", qty);
                //////cmd.Parameters.Add("@mprice", price);
                //////cmd.Parameters.Add("@mbranchid", "1064");
                //////cmd.Parameters.Add("@minstock", minstock);
                //////cmd.Parameters.Add("@maxstock", maxstock);
                //////vdm.insert(cmd);


                //////string itemname = dr["MATERIAL"].ToString();
                //////string catname = dr["Category Name"].ToString();
                //////string subcatname = dr["Sub Category Name"].ToString();
                //////string UOM = dr["UOM"].ToString();
                //////string minstock = dr["MinStock"].ToString();
                //////string maxstock = dr["MaxStock"].ToString();
                //////string qty = dr["Avilable Stores"].ToString();
                //////string price = dr["Price"].ToString();
                //////string amt = dr["AMOUNT"].ToString();
                //////string uomid = "";
                string productname = dr["Particulars"].ToString();
                string qty         = dr["ERP"].ToString();
                string days        = dr["Day cons"].ToString();
                cmd = new SqlCommand("SELECT productid FROM productmaster WHERE (productname=@productname)");
                cmd.Parameters.Add("@productname", productname);
                DataTable dtproducts = vdm.SelectQuery(cmd).Tables[0];
                if (dtproducts.Rows.Count > 0)
                {
                    cmd = new SqlCommand("update productmoniter  SET qty=@qty, perdayconcsumption=@perdayconcsumption WHERE  (productid=@productid) AND (branchid=@branchid)");
                    cmd.Parameters.Add("@productid", dtproducts.Rows[0]["productid"].ToString());
                    cmd.Parameters.Add("@qty", qty);
                    cmd.Parameters.Add("@branchid", "2");
                    if (days == "" || days == null)
                    {
                        days = "0";
                    }
                    cmd.Parameters.Add("@perdayconcsumption", days);
                    vdm.Update(cmd);
                }
                else
                {
                    DataRow newrow = dtmiss.NewRow();
                    newrow["Itemcode"]    = productname;
                    newrow["productname"] = productname;
                    dtmiss.Rows.Add(newrow);
                }
                i++;
            }
            grdmiss.DataSource = dtmiss;
            grdmiss.DataBind();
            Session["xportdata"] = dtmiss;
            Session["filename"]  = "report";
        }
        catch
        {
        }
        lblmsg.Text = "Records inserted successfully";
    }
Ejemplo n.º 10
0
    protected void login_click(object sender, EventArgs e)
    {
        try
        {
            vdm = new SalesDBManager();
            string userid = Usernme_txt.Text, password = Pass_pas.Text;
            cmd = new SqlCommand("SELECT branchmaster.gstin, branchmaster.branchledgername, branchmapping.mainbranch, employe_details.sno, employe_details.loginflag, employe_details.employename, employe_details.userid, employe_details.password, employe_details.emailid, employe_details.phone, employe_details.branchtype, employe_details.leveltype, employe_details.departmentid, employe_details.branchid, branchmaster.branchid AS Expr1, branchmaster.branchname, branchmaster.address, branchmaster.branchcode, branchmaster.phone AS Expr2, branchmaster.tino, branchmaster.stno, branchmaster.cstno, branchmaster.emailid AS Expr3, branchmaster.statename FROM employe_details INNER JOIN branchmaster ON employe_details.branchid = branchmaster.branchid INNER JOIN departmentmaster ON departmentmaster.sno=employe_details.departmentid INNER JOIN branchmapping ON branchmaster.branchid=branchmapping.subbranch WHERE (employe_details.userid = @userid) AND (employe_details.password = @pwd)");
            cmd.Parameters.Add("@pwd", password);
            cmd.Parameters.Add("@userid", userid);
            DataTable dt = vdm.SelectQuery(cmd).Tables[0];
            if (dt.Rows.Count > 0)
            {
                string loginflag = dt.Rows[0]["loginflag"].ToString();
                //if (loginflag == "False")
                //{
                string sno = dt.Rows[0]["sno"].ToString();
                cmd = new SqlCommand("update employe_details set loginflag=@log where sno=@sno");
                cmd.Parameters.Add("@log", "1");
                cmd.Parameters.Add("@sno", sno);
                vdm.Update(cmd);
                Session["TinNo"]       = "37921042267";
                Session["mainbranch"]  = dt.Rows[0]["mainbranch"].ToString();
                Session["Employ_Sno"]  = dt.Rows[0]["sno"].ToString();
                Session["Po_BranchID"] = dt.Rows[0]["branchid"].ToString();
                Session["stateid"]     = dt.Rows[0]["statename"].ToString();
                Session["TitleName"]   = "SRI VYSHNAVI DAIRY SPECIALITIES (P) LTD";
                string   julydt = "07/01/2017 12:00:00 AM";
                DateTime gst_dt = Convert.ToDateTime(julydt);
                DateTime today  = DateTime.Today;
                //if (today > gst_dt)
                //{
                Session["Address"] = dt.Rows[0]["address"].ToString();
                Session["gstin"]   = dt.Rows[0]["gstin"].ToString();
                //}
                //else
                //{
                //    Session["Address"] = "Survey No. 381-2, Punabaka Village, Pellakuru mandal SPSR Nellore (Dt) Pin - 524129, Andhra Pradesh,11. Email : [email protected] Phone: 7729995606; GSTIN NO: 37921042267.";
                //   // Session["Address"] = "Survey No. 381-2, Punabaka Village, Pellakuru mandal SPSR Nellore (Dt) Pin - 524129.Couriering address : No.45, Madhu apartments,Panagal-517640,Srikalahasthi,Chittoor(dt),AndhraPradesh. Email : [email protected];[email protected] Phone: 7729995606,7729995603,9382525913; GSTIN: 37921042267."; //dt.Rows[0]["address"].ToString();
                //}
                Session["BranchCode"]       = dt.Rows[0]["branchcode"].ToString();
                Session["TinNo"]            = "37921042267";
                Session["stno"]             = dt.Rows[0]["stno"].ToString();
                Session["cstno"]            = dt.Rows[0]["cstno"].ToString();
                Session["phone"]            = dt.Rows[0]["phone"].ToString();
                Session["emailid"]          = dt.Rows[0]["emailid"].ToString();
                Session["UserName"]         = dt.Rows[0]["employename"].ToString();
                Session["password"]         = dt.Rows[0]["password"].ToString();
                Session["BranchType"]       = dt.Rows[0]["branchtype"].ToString();
                Session["Department"]       = dt.Rows[0]["departmentid"].ToString();
                Session["leveltype"]        = dt.Rows[0]["leveltype"].ToString();
                Session["branchledgername"] = dt.Rows[0]["branchledgername"].ToString();


                string branchtype = dt.Rows[0]["BranchType"].ToString();
                string leveltype  = dt.Rows[0]["leveltype"].ToString();



                Response.Cookies["UserName"].Value   = HttpUtility.UrlEncode("true");
                Response.Cookies["UserName"].Path    = "/";
                Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(1);

                Response.Cookies["Employ_Sno"].Value   = HttpUtility.UrlEncode("true");
                Response.Cookies["Employ_Sno"].Path    = "/";
                Response.Cookies["Employ_Sno"].Expires = DateTime.Now.AddDays(1);

                //get ip address and device type
                string ipaddress;
                ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (ipaddress == "" || ipaddress == null)
                {
                    ipaddress = Request.ServerVariables["REMOTE_ADDR"];
                }
                DateTime ServerDateCurrentdate  = SalesDBManager.GetTime(vdm.conn);
                HttpBrowserCapabilities browser = Request.Browser;
                string devicetype  = "";
                string userAgent   = Request.ServerVariables["HTTP_USER_AGENT"];
                Regex  OS          = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                Regex  device      = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                string device_info = string.Empty;
                if (OS.IsMatch(userAgent))
                {
                    device_info = OS.Match(userAgent).Groups[0].Value;
                }
                if (device.IsMatch(userAgent.Substring(0, 4)))
                {
                    device_info += device.Match(userAgent).Groups[0].Value;
                }
                if (!string.IsNullOrEmpty(device_info))
                {
                    devicetype = device_info;
                    string[] words = devicetype.Split(')');
                    devicetype = words[0].ToString();
                }
                else
                {
                    devicetype = "Desktop";
                }


                //string alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                //string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
                //string numbers = "1234567890";

                //string characters = numbers;
                //characters += alphabets + small_alphabets + numbers;
                //int length = 8;
                //string otp = string.Empty;
                //for (int i = 0; i < length; i++)
                //{
                //    string character = string.Empty;
                //    do
                //    {
                //        int index = new Random().Next(0, characters.Length);
                //        character = characters.ToCharArray()[index].ToString();
                //    } while (otp.IndexOf(character) != -1);
                //    otp += character;
                //}
                cmd = new SqlCommand("INSERT INTO logininfo(userid, username, logintime, ipaddress, devicetype) values (@userid, @UserName, @logintime, @ipaddress, @device)");
                cmd.Parameters.Add("@userid", dt.Rows[0]["sno"].ToString());
                cmd.Parameters.Add("@UserName", Session["UserName"]);
                cmd.Parameters.Add("@logintime", ServerDateCurrentdate);
                cmd.Parameters.Add("@ipaddress", ipaddress);
                cmd.Parameters.Add("@device", devicetype);
                //cmd.Parameters.Add("@otp", otp);
                vdm.insert(cmd);
                // Session["leveltype"] = "Admin";
                if (leveltype == "Admin     ")
                {
                    Response.Redirect("chartdashboard.aspx", false);
                }
                if (leveltype == "SuperAdmin")
                {
                    Response.Redirect("chartdashboard.aspx", false);
                }
                if (leveltype == "User      ")
                {
                    Response.Redirect("InwardReport.aspx", false);
                }
                if (leveltype == "Operations")
                {
                    Response.Redirect("PoDashBoard.aspx", false);
                }
                if (leveltype == "Issue     ")
                {
                    Response.Redirect("IssueDashBoard.aspx", false);
                }
                if (leveltype == "Receipt   ")
                {
                    Response.Redirect("InwardDashboard.aspx", false);
                }
                if (leveltype == "Section   ")
                {
                    Response.Redirect("IndentEntry.aspx", false);
                }
                //}
                //else
                //{
                //    lblMsg.Text = "Already Some one Login With This User Name";
                //}
            }
            else
            {
                lblMsg.Text = "Invalid userId and Password";
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
Ejemplo n.º 11
0
    void GetReport()
    {
        try
        {
            lblmsg.Text          = "";
            pnlHide.Visible      = true;
            Session["RouteName"] = ddlSalesOffice.SelectedItem.Text;
            Session["IDate"]     = DateTime.Now.AddDays(1).ToString("dd/MM/yyyy");
            vdm = new SalesDBManager();
            DateTime fromdate = DateTime.Now;
            DateTime todate   = DateTime.Now;

            string[] dateFromstrig = txtFromdate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            dateFromstrig = dtp_Todate.Text.Split(' ');
            if (dateFromstrig.Length > 1)
            {
                if (dateFromstrig[0].Split('-').Length > 0)
                {
                    string[] dates = dateFromstrig[0].Split('-');
                    string[] times = dateFromstrig[1].Split(':');
                    todate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0);
                }
            }
            DataTable Report = new DataTable();
            Report.Columns.Add("DOE");
            Report.Columns.Add("Ref Receipt");
            Report.Columns.Add("Receipt");
            Report.Columns.Add("Type");
            Report.Columns.Add("Name");
            Report.Columns.Add("Amount").DataType = typeof(Double);
            lbl_selfromdate.Text = fromdate.ToString("dd/MM/yyyy");
            lblRoutName.Text     = ddlSalesOffice.SelectedItem.Text;
            DateTime ReportDate  = SalesDBManager.GetTime(vdm.conn);
            DateTime dtapril     = new DateTime();
            DateTime dtmarch     = new DateTime();
            int      currentyear = ReportDate.Year;
            int      nextyear    = ReportDate.Year + 1;
            if (ReportDate.Month > 3)
            {
                string apr = "4/1/" + currentyear;
                dtapril = DateTime.Parse(apr);
                string march = "3/31/" + nextyear;
                dtmarch = DateTime.Parse(march);
            }
            if (ReportDate.Month <= 3)
            {
                string apr = "4/1/" + (currentyear - 1);
                dtapril = DateTime.Parse(apr);
                string march = "3/31/" + (nextyear - 1);
                dtmarch = DateTime.Parse(march);
            }
            Session["xporttype"] = "TallyPayments";
            string ledger = "";
            Session["filename"] = ddlSalesOffice.SelectedItem.Text + " Tally Payments" + fromdate.ToString("dd/MM/yyyy");
            cmd = new SqlCommand("SELECT cashpayables.DOE, cashpayables.VocherID, subpayable.vouchercode, cashpayables.Sno, subpayable.HeadSno, cashpayables.Remarks,cashpayables.Remarks AS Expr1, subpayable.sno AS Expr2, subpayable.Amount, accountheads.HeadName,accountheads.ledger_code,  cashpayables.BranchID, Plant_Master.ladger_dr,Plant_Master.WHcode, Plant_Master.ladger_dr_code FROM cashpayables INNER JOIN subpayable ON cashpayables.Sno = subpayable.RefNo INNER JOIN accountheads ON subpayable.HeadSno = accountheads.Sno INNER JOIN Plant_Master ON cashpayables.BranchID = Plant_Master.Plant_Code WHERE (cashpayables.BranchID = @BranchID) AND (cashpayables.DOE BETWEEN @d1 AND @d2) AND (cashpayables.VoucherType = 'Debit') AND  (cashpayables.Status = 'P')");
            cmd.Parameters.Add("@BranchID", ddlSalesOffice.SelectedValue);
            cmd.Parameters.Add("@d1", GetLowDate(fromdate));
            cmd.Parameters.Add("@d2", GetHighDate(todate));
            DataTable dtAgent = vdm.SelectQuery(cmd).Tables[0];
            if (dtAgent.Rows.Count > 0)
            {
                DataView view = new DataView(dtAgent);
                dtReport = new DataTable();
                dtReport.Columns.Add("Voucher Date");
                dtReport.Columns.Add("Voucher No");
                dtReport.Columns.Add("Voucher Type");
                dtReport.Columns.Add("whcode");
                //dtReport.Columns.Add("ApprovedBy");
                dtReport.Columns.Add("Credit Code");
                dtReport.Columns.Add("Ledger (Cr)");
                dtReport.Columns.Add("Debit Code");
                dtReport.Columns.Add("Ledger (Dr)");
                dtReport.Columns.Add("Amount");
                dtReport.Columns.Add("Narration");
                int i = 1;
                foreach (DataRow branch in dtAgent.Rows)
                {
                    string VoucherNo = "";
                    cmd = new SqlCommand("SELECT  vouchercode,RefNo, HeadDesc, Amount, HeadSno, sno, branchid, paiddate FROM subpayable  WHERE (branchid = @BranchID) AND (paiddate BETWEEN @d1 AND @d2)");
                    cmd.Parameters.Add("@BranchID", ddlSalesOffice.SelectedValue);
                    cmd.Parameters.Add("@d1", GetLowDate(fromdate));
                    cmd.Parameters.Add("@d2", GetLowDate(fromdate));
                    DataTable dtVoucher = vdm.SelectQuery(cmd).Tables[0];
                    if (dtVoucher.Rows.Count > 0)
                    {
                        DataRow[] drvoucher = dtVoucher.Select("branchid='" + ddlSalesOffice.SelectedValue + "' and RefNo='" + branch["sno"].ToString() + "' and HeadSno='" + branch["HeadSno"].ToString() + "'");
                        if (drvoucher.Length > 0)
                        {
                            foreach (DataRow drv in drvoucher)
                            {
                                VoucherNo = drv.ItemArray[0].ToString();
                            }
                        }
                        else
                        {
                            cmd = new SqlCommand("SELECT  ISNULL(MAX(vouchercode), 0) + 1 AS Sno FROM subpayable WHERE (branchid = @branchid)  AND (paiddate BETWEEN @d1 AND @d2)");
                            cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                            cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                            cmd.Parameters.Add("@d1", GetLowDate(dtapril.AddDays(-1)));
                            cmd.Parameters.Add("@d2", GetHighDate(dtmarch.AddDays(-1)));
                            DataTable dtvoucherno = vdm.SelectQuery(cmd).Tables[0];
                            VoucherNo = dtvoucherno.Rows[0]["Sno"].ToString();
                            cmd       = new SqlCommand("update  subpayable set vouchercode=@vouchercode, paiddate=@paiddate,branchid=@branchid  where (RefNo=@RefNo) AND (HeadSno = @HeadSno)");;
                            cmd.Parameters.Add("@vouchercode", VoucherNo);
                            cmd.Parameters.Add("@paiddate", fromdate);
                            cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                            cmd.Parameters.Add("@RefNo", branch["sno"].ToString());
                            cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                            vdm.Update(cmd);
                        }
                    }
                    else
                    {
                        cmd = new SqlCommand("SELECT ISNULL(MAX(vouchercode), 0) + 1 AS Sno FROM subpayable WHERE (branchid = @branchid)  AND (paiddate BETWEEN @d1 AND @d2)");
                        cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                        cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                        cmd.Parameters.Add("@d1", GetLowDate(dtapril.AddDays(-1)));
                        cmd.Parameters.Add("@d2", GetHighDate(dtmarch.AddDays(-1)));
                        DataTable dtvoucherno = vdm.SelectQuery(cmd).Tables[0];
                        VoucherNo = dtvoucherno.Rows[0]["Sno"].ToString();
                        cmd       = new SqlCommand("update  subpayable set vouchercode=@vouchercode, paiddate=@paiddate,branchid=@branchid  where  (RefNo=@RefNo) AND (HeadSno = @HeadSno)");;
                        cmd.Parameters.Add("@vouchercode", VoucherNo);
                        cmd.Parameters.Add("@paiddate", fromdate);
                        cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                        cmd.Parameters.Add("@RefNo", branch["sno"].ToString());
                        cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                        vdm.Update(cmd);
                    }
                    if (VoucherNo == "0")
                    {
                        cmd = new SqlCommand("SELECT IFNULL(MAX(vouchercode), 0) + 1 AS Sno FROM subpayable WHERE (branchid = @branchid)  AND (paiddate BETWEEN @d1 AND @d2)");
                        cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                        cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                        cmd.Parameters.Add("@d1", GetLowDate(dtapril.AddDays(-1)));
                        cmd.Parameters.Add("@d2", GetHighDate(dtmarch.AddDays(-1)));
                        DataTable dtvoucherno = vdm.SelectQuery(cmd).Tables[0];
                        VoucherNo = dtvoucherno.Rows[0]["Sno"].ToString();
                        cmd       = new SqlCommand("update  subpayable set vouchercode=@vouchercode, paiddate=@paiddate,branchid=@branchid  where  (RefNo=@RefNo) AND (HeadSno = @HeadSno)");;
                        cmd.Parameters.Add("@vouchercode", VoucherNo);
                        cmd.Parameters.Add("@paiddate", fromdate);
                        cmd.Parameters.Add("@branchid", ddlSalesOffice.SelectedValue);
                        cmd.Parameters.Add("@RefNo", branch["sno"].ToString());
                        cmd.Parameters.Add("@HeadSno", branch["HeadSno"].ToString());
                        vdm.Update(cmd);
                    }
                    string NewVoucherNo = "0";
                    int    countdc      = 0;
                    int.TryParse(VoucherNo, out countdc);
                    if (countdc <= 10)
                    {
                        NewVoucherNo = "000" + countdc;
                    }
                    if (countdc >= 10 && countdc <= 99)
                    {
                        NewVoucherNo = "00" + countdc;
                    }
                    if (countdc >= 99 && countdc <= 999)
                    {
                        NewVoucherNo = "0" + countdc;
                    }
                    DataRow newrow = dtReport.NewRow();

                    string   Date      = branch["DOE"].ToString();
                    DateTime from_date = Convert.ToDateTime(Date);
                    newrow["Voucher Date"] = from_date.ToString("dd-MMM-yyyy");
                    newrow["Voucher No"]   = ddlSalesOffice.SelectedValue + dtapril.ToString("yy") + dtmarch.ToString("yy") + NewVoucherNo;
                    newrow["Voucher Type"] = "Cash Payment Import";
                    newrow["Ledger (Cr)"]  = branch["ladger_dr"].ToString();
                    newrow["Debit Code"]   = branch["ledger_code"].ToString();
                    newrow["Credit Code"]  = branch["ladger_dr_code"].ToString();
                    newrow["Ledger (Dr)"]  = branch["HeadName"].ToString();
                    newrow["Amount"]       = branch["Amount"].ToString();
                    newrow["whcode"]       = branch["WHcode"].ToString();
                    double invval = 0;
                    newrow["Narration"] = branch["Remarks"].ToString() + ",VoucherID  " + VoucherNo + ",Emp Name  " + Session["EmpName"].ToString();
                    dtReport.Rows.Add(newrow);
                    i++;
                }
                grdReports.DataSource = dtReport;
                grdReports.DataBind();
                Session["xportdata"] = dtReport;
            }
            else
            {
                pnlHide.Visible       = false;
                lblmsg.Text           = "No Indent Found";
                grdReports.DataSource = dtReport;
                grdReports.DataBind();
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text           = ex.Message;
            grdReports.DataSource = dtReport;
            grdReports.DataBind();
        }
    }
Ejemplo n.º 12
0
 protected void login_click(object sender, EventArgs e)
 {
     try
     {
         username           = Usernme_txt.Text;
         password           = Pass_pas.Text;
         lbl_username.Text  = username;
         lbl_passwords.Text = password;
         DateTime ServerDateCurrentdate = SalesDBManager.GetTime(vdm.conn);
         //cmd = new SqlCommand("SELECT employee_erp.sno, employee_erp.leveltype,employee_erp.loginstatus, branch_info.venorid, employee_erp.empname, employee_erp.deptid, employee_erp.username, employee_erp.passward, employee_erp.emptype, employee_erp.branchid, branch_info.branchtype,branch_info.address,branch_info.branchname,branch_info.tinno FROM employee_erp INNER JOIN branch_info ON employee_erp.branchid = branch_info.sno WHERE  (employee_erp.username = @UN) AND (employee_erp.passward = @Pwd)");
         cmd = new SqlCommand("SELECT employee_erp.sno, employee_erp.leveltype,employee_erp.loginstatus, branch_info.venorid, branch_info.branchcode, employee_erp.empname, employee_erp.deptid, employee_erp.username, employee_erp.passward, employee_erp.emptype, employee_erp.branchid, branch_info.branchtype,branch_info.address,branch_info.branchname,branch_info.tinno, employee_erp.phoneno, employee_erp.otpstatus,employee_erp.empid FROM employee_erp INNER JOIN branch_info ON employee_erp.branchid = branch_info.sno WHERE  (employee_erp.username = @UN) AND (employee_erp.passward = @Pwd)");
         cmd.Parameters.Add("@Pwd", password);
         cmd.Parameters.Add("@UN", username);
         DataTable dt = vdm.SelectQuery(cmd).Tables[0];
         if (dt.Rows.Count > 0)
         {
             string otpstatus = dt.Rows[0]["otpstatus"].ToString();
             if (otpstatus == "1")
             {
                 //session
                 string sno = dt.Rows[0]["sno"].ToString();
                 cmd = new SqlCommand("update employee_erp set loginstatus=@log where sno=@sno");
                 cmd.Parameters.Add("@log", "1");
                 cmd.Parameters.Add("@sno", sno);
                 vdm.Update(cmd);
                 Session["TitleName"]  = dt.Rows[0]["branchname"].ToString(); // "SRI VYSHNAVI DAIRY SPECIALITIES (P) LTD";
                 Session["TinNo"]      = dt.Rows[0]["tinno"].ToString();
                 Session["DeptID"]     = dt.Rows[0]["deptid"].ToString();
                 Session["Employ_Sno"] = dt.Rows[0]["sno"].ToString();
                 Session["Branch_ID"]  = dt.Rows[0]["branchid"].ToString();
                 Session["Emp_Type"]   = dt.Rows[0]["emptype"].ToString();
                 Session["Address"]    = dt.Rows[0]["address"].ToString(); //"R.S.No:381/2,Punabaka village Post,Pellakuru Mandal,Nellore District -524129., ANDRAPRADESH (State).Phone: 9440622077, Fax: 044 – 26177799. ";// dt.Rows[0]["brnch_address"].ToString();
                 Session["BranchType"] = dt.Rows[0]["branchtype"].ToString();
                 Session["leveltype"]  = dt.Rows[0]["leveltype"].ToString();
                 Session["UserName"]   = dt.Rows[0]["empname"].ToString();
                 Session["VendorID"]   = dt.Rows[0]["venorid"].ToString();
                 Session["loginflag"]  = dt.Rows[0]["loginstatus"].ToString();
                 Session["branchcode"] = dt.Rows[0]["branchcode"].ToString();
                 Session["HRMS_EmpId"] = dt.Rows[0]["empid"].ToString();
                 string hostName = Dns.GetHostName(); // Retrive the Name of HOST
                 //get ip address and device type
                 ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                 if (ipaddress == "" || ipaddress == null)
                 {
                     ipaddress = Request.ServerVariables["REMOTE_ADDR"];
                 }
                 HttpBrowserCapabilities browser = Request.Browser;
                 string devicetype  = "";
                 string userAgent   = Request.ServerVariables["HTTP_USER_AGENT"];
                 Regex  OS          = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                 Regex  device      = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                 string device_info = string.Empty;
                 if (OS.IsMatch(userAgent))
                 {
                     device_info = OS.Match(userAgent).Groups[0].Value;
                 }
                 if (device.IsMatch(userAgent.Substring(0, 4)))
                 {
                     device_info += device.Match(userAgent).Groups[0].Value;
                 }
                 if (!string.IsNullOrEmpty(device_info))
                 {
                     devicetype = device_info;
                     string[] words = devicetype.Split(')');
                     devicetype = words[0].ToString();
                 }
                 else
                 {
                     devicetype = "Desktop";
                 }
                 cmd = new SqlCommand("INSERT INTO logininfo(UserId, UserName, Logintime, IpAddress,devicetype,status) values (@userid, @UserName, @logintime, @ipaddress,@devicetype,@status)");
                 cmd.Parameters.Add("@userid", dt.Rows[0]["sno"].ToString());
                 cmd.Parameters.Add("@UserName", Session["UserName"]);
                 cmd.Parameters.Add("@logintime", ServerDateCurrentdate);
                 cmd.Parameters.Add("@ipaddress", ipaddress);
                 cmd.Parameters.Add("@devicetype", devicetype);
                 cmd.Parameters.Add("@status", "1");
                 vdm.insert(cmd);
                 //End
                 //otp
                 string Id         = string.Empty;
                 string no         = dt.Rows[0]["phoneno"].ToString();
                 string empid      = dt.Rows[0]["sno"].ToString();
                 string numbers    = "1234567890";
                 string characters = numbers;
                 int    length     = 6;
                 string otp        = string.Empty;
                 for (int i = 0; i < length; i++)
                 {
                     string character = string.Empty;
                     do
                     {
                         int index = new Random().Next(0, characters.Length);
                         character = characters.ToCharArray()[index].ToString();
                     } while (otp.IndexOf(character) != -1);
                     otp += character;
                 }
                 DateTime sdt        = SalesDBManager.GetTime(vdm.conn);
                 int      h          = Convert.ToInt32(sdt.ToString("HH"));
                 int      m          = 0;
                 string   otpexptime = string.Empty;
                 string   sss        = string.Empty;
                 string   mm         = string.Empty;
                 m = Convert.ToInt32(sdt.ToString("mm")) + 3;
                 int ss = Convert.ToInt32(sdt.ToString("ss"));
                 if (ss > 60)
                 {
                     ss = ss - 60;
                 }
                 if (ss < 10)
                 {
                     sss = "0" + m.ToString();
                 }
                 if (m > 60)
                 {
                     m = m - 60;
                 }
                 if (m < 10)
                 {
                     if (ss < 10)
                     {
                         mm         = "0" + m.ToString();
                         otpexptime = h.ToString() + ":" + mm.ToString() + ":" + sss.ToString();
                     }
                     else
                     {
                         mm         = m.ToString();
                         otpexptime = h.ToString() + ":" + mm.ToString() + ":" + ss.ToString();
                     }
                 }
                 else
                 {
                     if (ss < 10)
                     {
                         otpexptime = h.ToString() + ":" + m.ToString() + ":" + sss.ToString();
                     }
                     else
                     {
                         otpexptime = h.ToString() + ":" + m.ToString() + ":" + ss.ToString();
                     }
                 }
                 Otpupdate(no, otp, otpexptime, empid);
                 Id = Encrypt(no.Trim());
                 string hyperlink = "otp.aspx?Id=" + Id.Trim();
                 string message1  = "OTP for  " + empid + "  Login : "******". Valid till " + otpexptime + "  Do not share OTP for security reasons.";
                 string strUrl    = "http://123.63.33.43/blank/sms/user/urlsms.php?username=vyshnavidairy&pass=vyshnavi@123&senderid=VYSAKG&dest_mobileno=" + no + "&message=" + message1 + "&response=Y";
                 //string strUrl = "http://103.16.101.52:8080/sendsms/bulksms?username=kapd-vyshnavi&password=vysavi&type=0&dlr=1&destination=" + no + "&source=VYSHRM&message=" + message1 + "";
                 WebRequest      request    = HttpWebRequest.Create(strUrl);
                 HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
                 Stream          s          = (Stream)response.GetResponseStream();
                 StreamReader    readStream = new StreamReader(s);
                 string          dataString = readStream.ReadToEnd();
                 response.Close();
                 s.Close();
                 readStream.Close();
                 string msg = hyperlink;
                 Response.Redirect("otp.aspx?Id=" + Id.Trim());
             }
             else
             {
                 fill_login_details();
             }
         }
         else
         {
             lbl_validation.Text = "Check Your Username and password";
         }
     }
     catch (Exception ex)
     {
         lbl_validation.Text = ex.Message;
     }
 }