/// <summary> /// This method is used to view the report. /// </summary> protected void btnview_Click(object sender, System.EventArgs e) { try { PetrolPumpClass obj=new PetrolPumpClass(); //SqlDataReader SqlDtr; //***string sql; //** sql="select firmname m1,place m2,contactper m3,teleno m4,type m5,regcustomer m6,potential m7,servo m8,castrol m9,shell m10,bpcl m11,veedol m12,elf m13,hpcl m14,pennzoil m15,spurious m16 from marketcustomerentry1"; //** SqlDtr =obj.GetRecordSet(sql); //** Gridmpr.DataSource=SqlDtr; //** if(SqlDtr.HasRows) //** { //** Gridmpr.DataBind(); //** Gridmpr.Visible=true; //** } //** else //** { //** MessageBox.Show("Data not available"); //** Gridmpr.Visible=false; //** return; //** } //** SqlDtr.Close(); strorderby="m1 ASC"; Session["Column"]="m1"; Session["order"]="ASC"; Bindthedata(); CreateLogFiles.ErrorLog("Form:Marketpotentialreport.aspx,Class:PetrolPumpClass.cs,Method:btnview_Click" +" Marketpotentialreport Viewed "+" userid "+uid); } catch(Exception ex) { CreateLogFiles.ErrorLog("Form:Marketpotentialreport.aspx,Class:PetrolPumpClass.cs,Method: btnview_Click " +" Marketpotentialreport Viewed "+ ex.Message+" EXCEPTION " +" userid "+uid); } }
protected void Page_Load(object sender, System.EventArgs e) { try { string check = ""; Cal_Img1.Visible = false; // check string gets the value from the check() method present in Security.dll; check = MySecurity.MySecurity.check(); // If the return value is false then the activation period expired and redirect to the error.aspx if (check.Equals("false")) { Response.Redirect("..\\Sysitem\\error.aspx", false); return; } // If the return value is Service then the Print_WindowsService is stopped and redirect to the Service.aspx if (check.Equals("Service")) { Response.Redirect("..\\Sysitem\\Service.aspx", false); return; } // If the return value is starts with P then dispaly the activation period. if (!check.Equals("")) { if (!check.Equals("true") && check.StartsWith("P")) { lblMessage.Text = check.Substring(1) + " left for Activation"; Cal_Img.Disabled = true; Cal_Img.Visible = false; Cal_Img1.Visible = true; Cal_Img1.Disabled = true; } } Session.Clear(); if (!IsPostBack) { PetrolPumpClass obj = new PetrolPumpClass(); SqlDataReader SqlDtr; string sql; // Fetch the roles and fills the User Type combo. sql = "select Role_Name from Roles"; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { DropUser.Items.Add(SqlDtr.GetValue(0).ToString()); } SqlDtr.Close(); txtSetDate.Text = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
protected void printBtn_Click(object sender, System.EventArgs e) { // The follwing code saves the credit bill as well as print it. if (DropCustID.SelectedIndex == 0) { MessageBox.Show("Please Select the Customer Name"); return; } string sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name,qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1) and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id"; PetrolPumpClass obj = new PetrolPumpClass(); PetrolPumpClass obj1 = new PetrolPumpClass(); SqlDataReader SqlDtr2 = obj.GetRecordSet(sql); string sql1 = ""; try { while (SqlDtr2.Read()) { DateTime dt = System.Convert.ToDateTime(SqlDtr2.GetValue(2).ToString()); string str1 = dt.ToShortDateString(); string str2 = SqlDtr2.GetValue(1).ToString(); string str3 = SqlDtr2.GetValue(4).ToString(); string str4 = SqlDtr2.GetValue(5).ToString(); string str5 = SqlDtr2.GetValue(6).ToString(); string str6 = SqlDtr2.GetValue(7).ToString(); string str7 = SqlDtr2.GetValue(3).ToString(); sql1 = "insert into Print_Credit_Bill(Bill_No,Bill_date,Slip_no,Particulars,Qty,Rate,Amount,Vehicle_No)values('" + lblBillNo.Text.ToString() + "'," + str1 + "," + str2 + ",'" + str3 + "'," + str4 + "," + str5 + "," + str6 + ",'" + str7 + "')"; obj1.InsertRecord(sql1); } SqlDtr2.Close(); CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:Print Bill No." + lblBillNo.Text.ToString() + " Saved. User Id = " + uid); MessageBox.Show("Credit Bill Saved"); reportmaking(); Print(); GetNextBillNo(); checkPrevileges(); txtDateFrom.Text = DateTime.Today.Day.ToString() + "/" + DateTime.Today.Month.ToString() + "/" + DateTime.Today.Year.ToString(); txtDateTO.Text = DateTime.Today.Day.ToString() + "/" + DateTime.Today.Month.ToString() + "/" + DateTime.Today.Year.ToString(); DropCustID.SelectedIndex = 0; GridCreditBill.DataSource = null; GridCreditBill.DataBind(); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:Print " + sql1 + " =====" + ex.Message + " EXCEPTION " + uid); } }
//This is used to bind the grid. public void displayReport() { try { PetrolPumpClass obj1 = new PetrolPumpClass(); TextBox1.Text = DropCustID.SelectedValue.ToString(); InventoryClass obj = new InventoryClass(); SqlDataReader SqlDtr; string sql = ""; #region Bind DataGrid if (DropVehicleNo.SelectedIndex == 0) { sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name, qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1) and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.sales_type = 'credit' and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id"; } else { sql = "select sm.invoice_no, slip_no, invoice_date, vehicle_no, prod_Name+ ' ' +Pack_Type Prod_Name, qty, rate, amount from sales_master sm, sales_details sd, products p where sm.invoice_date between '" + ToMMddYYYY(txtDateFrom.Text) + "' and dateadd(day,1,'" + ToMMddYYYY(txtDateTO.Text) + "') and sm.cust_id in ( select cust_id from customer where cust_name=substring('" + DropCustID.SelectedItem.Value + "',1,charindex(':','" + DropCustID.SelectedItem.Value + "')-1) and city=substring('" + DropCustID.SelectedItem.Value + "',charindex(':','" + DropCustID.SelectedItem.Value + "')+1,len('" + DropCustID.SelectedItem.Value + "'))) and sm.sales_type = 'credit' and sm.invoice_no = sd.invoice_no and sd.prod_id = p.prod_id and Vehicle_No = '" + DropVehicleNo.SelectedItem.Text + "'"; } SqlDtr = obj.GetRecordSet(sql); GridCreditBill.DataSource = SqlDtr; GridCreditBill.DataBind(); if (GridCreditBill.Items.Count == 0) { MessageBox.Show("Data not available"); GridCreditBill.Visible = false; } else { GridCreditBill.Visible = true; } SqlDtr.Close(); checkPrevileges(); #endregion CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx,Class:PetrolPumpClass.cs,Method:displayReport() Credit Bill Viewed for Bill NO " + lblBillNo.Text.ToString() + " Userid " + uid); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx ,method :displayReport() " + " Coustmer :" + DropCustID.SelectedValue.ToString() + " is Selected " + ex.Message + " EXCEPTION " + " Userid " + uid); } }
protected string Multiply1(string inv_no) { PetrolPumpClass obj = new PetrolPumpClass(); SqlDataReader SqlDtr; string sql; in_amt = 0; if (Flag == 0) { Cache["Invoice_No"] = inv_no; Flag = 1; } else if (Flag == 3) { Cache["Invoice_No"] = inv_no; } if (status == 0) { sql = "select count(*) from vw_SaleBook where Invoice_No=" + Cache["Invoice_No"].ToString() + ""; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { count += int.Parse(SqlDtr.GetValue(0).ToString()); } SqlDtr.Close(); status = 1; } if (i < count) { Flag = 2; i++; } if (i == count) { //amt1=amt; sql = "select Net_amount from sales_master where Invoice_No=" + Cache["Invoice_No"].ToString() + ""; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { amt1 = double.Parse(SqlDtr.GetValue(0).ToString()); } SqlDtr.Close(); //amt=0; status = 0; i = 0; Flag = 3; count = 0; } else { amt1 = 0; Flag = 4; } if (Flag == 4) { return(" --- "); } else if (Flag == 3) { am += amt1; Cache["am"] = am; return(GenUtil.strNumericFormat(amt1.ToString())); } return(""); }
/// <summary> /// This method is used to check the user is valid or not after that check permission of that user from database. /// </summary> private void btnSign_ServerClick(object sender, System.Web.UI.ImageClickEventArgs e) { CreateLogFiles.ErrorLog("Form:Login.aspx,Method: btnSign_Click, Login Type " + DropUser.SelectedItem.Text + " and Login User " + txtUserLogin.Text); PetrolPumpClass obj = new PetrolPumpClass(); try { SqlDataReader SqlDtr; string sql; string User_ID = ""; string[,] Privileges = new string[98, 6]; /****add-bhal****/ Session["CurrentDate"] = txtSetDate.Text.ToString(); #region Check for Valid User string pwd = ""; string epassword = ""; sql = "select Password from User_Master where LoginName='" + txtUserLogin.Text + "'"; SqlDtr = obj.GetRecordSet(sql); if (SqlDtr.Read()) { pwd = MySecurity.MySecurity.Decrypt(SqlDtr.GetValue(0).ToString(), "!@#$%^"); if (txtPasswd.Text == pwd) { epassword = SqlDtr.GetValue(0).ToString(); SqlDtr.Close(); } else { RMG.MessageBox.Show("Invalid User Login Name or Password"); return; } } else { RMG.MessageBox.Show("Invalid User Login Name or Password"); return; } SqlDtr.Close(); // Calls the method contactServer by passing the selected date to set the system date as a selected date. string ss = MySecurity.MySecurity.contactServer("[CD]" + convertDate(txtSetDate.Text)); // contactServer("[CD]"+convertDate(TxtDateFrom.Text)); #region get the message from Organisation table and put into session to display in all the invoices dbobj.SelectQuery("Select Message from organisation where CompanyID = 1001", ref SqlDtr); if (SqlDtr.Read()) { Session["Message"] = SqlDtr.GetValue(0).ToString(); } else { Session["Message"] = ""; } SqlDtr.Close(); #endregion #region get the VAT_Rate from Organisation table and put into session to access in Sales and Purchase Invoice. dbobj.SelectQuery("Select VAT_Rate from organisation where CompanyID = 1001", ref SqlDtr); if (SqlDtr.Read()) { Session["VAT_Rate"] = SqlDtr.GetValue(0).ToString(); } else { Session["VAT_Rate"] = ""; } SqlDtr.Close(); #endregion #region get the EntryTax from Organisation table and put into session to access in Sales and Purchase Invoice. dbobj.SelectQuery("Select Entrytax from organisation where CompanyID = 1001", ref SqlDtr); if (SqlDtr.Read()) { Session["Entrytax"] = SqlDtr.GetValue(0).ToString(); } else { Session["Entrytax"] = ""; } SqlDtr.Close(); #endregion #region select the user id ,password compare and stored in a session variable. sql = "select UserID, LoginName,password,Role_Name from User_Master um, Roles r where um.role_ID=r.role_ID and um.LoginName='" + txtUserLogin.Text + "' and password='******' and r.Role_ID=(select Role_ID from Roles where Role_Name='" + DropUser.SelectedItem.Value + "')"; SqlDtr = obj.GetRecordSet(sql); if (SqlDtr.Read()) { User_ID = SqlDtr.GetValue(0).ToString(); Session["User_ID"] = User_ID; //string sss=SqlDtr.GetValue(1).ToString(); Session["User_Name"] = (SqlDtr.GetValue(1).ToString()); //string sss1=(Session["User_Name"].ToString()); Cache["User_Name"] = (SqlDtr.GetValue(1).ToString()); Session["PASSWORD"] = SqlDtr.GetValue(2).ToString(); Session["User_Type"] = SqlDtr.GetValue(3).ToString(); SqlDtr.Close(); } else { RMG.MessageBox.Show("Invalid User Login Name or Password"); return; } SqlDtr.Close(); #endregion #endregion if (User_ID != "") { #region Get The User Permission sql = "select * from Privileges where User_ID='" + User_ID + "'"; SqlDtr = obj.GetRecordSet(sql); for (int i = 0; SqlDtr.Read(); i++) { for (int j = 0; j < 6; j++) { Privileges[i, j] = SqlDtr.GetValue(j + 1).ToString(); } } SqlDtr.Close(); //Session["Privileges"]=Privileges; Cache["Privileges"] = Privileges; #endregion Response.Redirect("HomePage.aspx", false); } else { RMG.MessageBox.Show("Invalid User Login Name or Password"); return; } txtUserLogin.Enabled = true; txtPasswd.Enabled = true; } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:Login.aspx,Method: btnSign_Click, Login Type " + DropUser.SelectedItem.Text + " EXCEPTION " + ex.ToString() + " and Login User " + txtUserLogin.Text); } }
/// <summary> /// This method is used for setting the Session variable for userId /// and also check accessing priviledges for particular user. /// </summary> protected void Page_Load(object sender, System.EventArgs e) { //SqlDataReader SqlDtr; PetrolPumpClass obj = new PetrolPumpClass(); // string sql="Select Dealername,dealership,address,foodlicno,wm from organisation where CompanyID = 1001"; // SqlDtr =obj.GetRecordSet(sql); // if(SqlDtr.Read()) // { // str1 = SqlDtr.GetValue(0).ToString()+","+SqlDtr.GetValue(1).ToString()+SqlDtr.GetValue(2).ToString(); // str2 = SqlDtr.GetValue(3).ToString(); // str3 = SqlDtr.GetValue(4).ToString(); // } // else // { // str1 = ""; // str2 = ""; // str3 =""; // } // SqlDtr.Close(); try { uid = (Session["User_Name"].ToString()); } catch (Exception es) { CreateLogFiles.ErrorLog("Form:SadbhavnaSchemeMonthWise.aspx,Method:page_load EXCEPTION " + es.Message + " userid " + uid); Response.Redirect("../../Sysitem/ErrorPage.aspx", false); return; } txtDateFrom.Text = Request.Form["txtDateFrom"] == null ? DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year.ToString() : Request.Form["txtDateFrom"].ToString(); Textbox1.Text = Request.Form["Textbox1"] == null ? DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year.ToString() : Request.Form["Textbox1"].ToString(); if (!Page.IsPostBack) { GridSalesReport.Visible = false; #region Check Privileges int i; string View_flag = "0", Add_Flag = "0", Edit_Flag = "0", Del_Flag = "0"; string Module = "5"; string SubModule = "40"; string[,] Priv = (string[, ])Session["Privileges"]; for (i = 0; i < Priv.GetLength(0); i++) { if (Priv[i, 0] == Module && Priv[i, 1] == SubModule) { View_flag = Priv[i, 2]; Add_Flag = Priv[i, 3]; Edit_Flag = Priv[i, 4]; Del_Flag = Priv[i, 5]; break; } } if (View_flag == "0") { Response.Redirect("../../Sysitem/AccessDeny.aspx", false); } #endregion txtDateFrom.Text = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year; Textbox1.Text = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year; } txtDateFrom.Text = Request.Form["txtDateFrom"] == null?GenUtil.str2DDMMYYYY(System.DateTime.Now.ToShortDateString()) : Request.Form["txtDateFrom"].ToString().Trim(); Textbox1.Text = Request.Form["Textbox1"] == null?GenUtil.str2DDMMYYYY(System.DateTime.Now.ToShortDateString()) : Request.Form["Textbox1"].ToString().Trim(); }
protected string Multiply1(string inv_no, string inv) { PetrolPumpClass obj = new PetrolPumpClass(); SqlDataReader SqlDtr; string sql; in_amt = 0; if (Flag == 0) { Cache["Invoice_No"] = inv_no; Flag = 1; } else if (Flag == 3) { Cache["Invoice_No"] = inv_no; } if (status == 0) { sql = "select count(*) from vw_PurchaseBook3 where Vndr_Invoice_No=" + Cache["Invoice_No"].ToString() + " and cast(floor(cast(vndr_invoice_date as float)) as datetime) >= '" + GenUtil.str2MMDDYYYY(Session["From_Date"].ToString()) + "' and cast(floor(cast(vndr_invoice_date as float)) as datetime) <= '" + GenUtil.str2MMDDYYYY(Session["To_Date"].ToString()) + "'"; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { count += int.Parse(SqlDtr.GetValue(0).ToString()); } SqlDtr.Close(); status = 1; } if (i < count) { Flag = 2; i++; } if (i == count) { //amt1=amt; amt1 = 0; sql = "select Net_amount from Purchase_master where vndr_Invoice_No=" + Cache["Invoice_No"].ToString() + " and cast(floor(cast(vndr_invoice_date as float)) as datetime) >= '" + GenUtil.str2MMDDYYYY(Session["From_Date"].ToString()) + "' and cast(floor(cast(vndr_invoice_date as float)) as datetime) <= '" + GenUtil.str2MMDDYYYY(Session["To_Date"].ToString()) + "' "; SqlDtr = obj.GetRecordSet(sql); while (SqlDtr.Read()) { amt1 += double.Parse(SqlDtr.GetValue(0).ToString()); } SqlDtr.Close(); //amt=0; status = 0; i = 0; Flag = 3; count = 0; } else { amt1 = 0; Flag = 4; } if (Flag == 4) { return(" --- "); } else if (Flag == 3) { am += amt1; Cache["am"] = am; return(GenUtil.strNumericFormat(amt1.ToString())); } return(""); }
protected void DropCustID_SelectedIndexChanged(object sender, System.EventArgs e) { try { PetrolPumpClass obj1 = new PetrolPumpClass(); TextBox1.Text = DropCustID.SelectedValue.ToString(); if (DropCustID.SelectedIndex == 0) { MessageBox.Show("Please Select Customer Name"); return; } InventoryClass obj = new InventoryClass(); SqlDataReader SqlDtr = null; string temp = DropCustID.SelectedItem.Text.Trim(); string[] arr = temp.Split(new char[] { ':' }, temp.Length); SqlDtr = obj.GetRecordSet("Select cv.* from Customer_Vehicles cv, Customer c where cv.Cust_id = c.Cust_id and c.Cust_Name='" + arr[0].Trim() + "' and c.City = '" + arr[1].Trim() + "'"); DropVehicleNo.Items.Clear(); DropVehicleNo.Items.Add("All"); if (SqlDtr.HasRows) { while (SqlDtr.Read()) { if (!SqlDtr.GetValue(2).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(2).ToString().Trim()); } if (!SqlDtr.GetValue(3).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(3).ToString().Trim()); } if (!SqlDtr.GetValue(4).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(4).ToString().Trim()); } if (!SqlDtr.GetValue(5).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(5).ToString().Trim()); } if (!SqlDtr.GetValue(6).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(6).ToString().Trim()); } if (!SqlDtr.GetValue(7).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(7).ToString().Trim()); } if (!SqlDtr.GetValue(8).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(8).ToString().Trim()); } if (!SqlDtr.GetValue(9).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(9).ToString().Trim()); } if (!SqlDtr.GetValue(10).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(10).ToString().Trim()); } if (!SqlDtr.GetValue(11).ToString().Trim().Equals("")) { DropVehicleNo.Items.Add(SqlDtr.GetValue(11).ToString().Trim()); } } } SqlDtr.Close(); displayReport(); } catch (Exception ex) { CreateLogFiles.ErrorLog("Form:Credit_Bill.aspx ,method :DropCustID_SelectedIndexChanged " + " Coustmer :" + DropCustID.SelectedValue.ToString() + " is Selected " + ex.Message + " EXCEPTION " + " Userid " + uid); } }