public void btn_pop1save_Click(object sender, EventArgs e) { try { bool saveflage = false; string getdate = Convert.ToString(txt_pop1date.Text); string[] splitdate = getdate.Split('-'); splitdate = splitdate[0].Split('/'); DateTime dt = new DateTime(); if (splitdate.Length > 0) { dt = Convert.ToDateTime(splitdate[1] + "/" + splitdate[0] + "/" + splitdate[2]); } string getday = dt.ToString("MM/dd/yyyy"); Fpspread2.SaveChanges(); for (int i = 0; i < Fpspread2.Sheets[0].RowCount; i++) { string menuname1 = Convert.ToString(Fpspread2.Sheets[0].Cells[i, 1].Text); string menupk = Convert.ToString(Fpspread2.Sheets[0].Cells[i, 1].Tag); string Qunty = Convert.ToString(Fpspread2.Sheets[0].Cells[i, 2].Text); string amount = Convert.ToString(Fpspread2.Sheets[0].Cells[i, 3].Text); if (Qunty.Trim() != "" && amount.Trim() != "") { //string q = "if exists (select * from MenuCost_Master where SessionMenu_Code ='" + menucode1 + "' and From_Date ='" + dt.ToString("MM/dd/yyyy") + "')update MenuCost_Master set Qty='" + Qunty + "',Cost ='" + amount + "',Menu_Name='" + menuname1 + "' where SessionMenu_Code ='" + menucode1 + "' and From_Date ='" + dt.ToString("MM/dd/yyyy") + "' else insert into MenuCost_Master (SessionMenu_Code,From_Date,Qty,Cost,Menu_Name) values ('" + menucode1 + "','" + dt.ToString("MM/dd/yyyy") + "','" + Qunty + "','" + amount + "','" + menuname1 + "')"; string q = " if exists (select * from HM_MenuCostMaster where MenuMasterFK ='" + menupk + "' and Menucost_Date='" + getday + "')update HM_MenuCostMaster set MenuQty ='" + Qunty + "',MenuAmount ='" + amount + "',Menucost_Date='" + getday + "' where MenuMasterFK ='" + menupk + "' else insert into HM_MenuCostMaster (MenuAmount,MenuMasterFK,MenuQty,Menucost_Date) values ('" + amount + "','" + menupk + "' ,'" + Qunty + "','" + getday + "')"; int ins = d2.update_method_wo_parameter(q, "Text"); if (ins != 0) { saveflage = true; } } } if (saveflage == true) { lblerror1.Visible = false; imgdiv2.Visible = true; lblalerterr.Text = "Saved Successfully"; clear(); } else { lblerror1.Visible = false; imgdiv2.Visible = true; lblalerterr.Text = "Please Enter The Field"; } } catch (Exception ex) { } }
public void btn_go_Click(object sender, EventArgs e) { try { Printcontrol.Visible = false; if (txt_hostelname.Text.Trim() != "--Select--" && txt_groupname.Text.Trim() != "--Select--" && txt_description.Text.Trim() != "--Select--") { DateTime dt = new DateTime(); DateTime dt1 = new DateTime(); string firstdate = Convert.ToString(txt_fromdate.Text); string seconddate = Convert.ToString(txt_todate.Text); string[] split = firstdate.Split('/'); dt = Convert.ToDateTime(split[1] + "/" + split[0] + "/" + split[2]); string[] split1 = seconddate.Split('/'); dt1 = Convert.ToDateTime(split1[1] + "/" + split1[0] + "/" + split1[2]); string hostel = ""; for (int i = 0; i < cbl_hostelname.Items.Count; i++) { if (cbl_hostelname.Items[i].Selected == true) { if (hostel == "") { hostel = "" + cbl_hostelname.Items[i].Value.ToString() + ""; } else { hostel = hostel + "'" + "," + "" + "'" + cbl_hostelname.Items[i].Value.ToString() + ""; } } } string group = ""; for (int i = 0; i < cbl_groupname.Items.Count; i++) { if (cbl_groupname.Items[i].Selected == true) { if (group == "") { group = "" + cbl_groupname.Items[i].Value.ToString() + ""; } else { group = group + "'" + "," + "" + "'" + cbl_groupname.Items[i].Value.ToString() + ""; } } } string gn = d2.GetFunction(""); string q1 = ""; if (rdb_datewise.Checked == true) { // q1 = "select CONVERT(varchar(10), Entry_Date,103) as Entry_Date, hd.Hostel_Name,hi.IncGroup_Code,(select TextVal from TextValTable where TextCode = ISNULL( hi.IncGroup_Code,0)) as IncGroup_Code_txt,hi.Inc_Amount,hi.Inc_Description from Hostel_Income hi,Hostel_Details hd where hd.Hostel_code=hi.Hostel_Code and hd.college_code='" + collegecode1 + "' and hi.Entry_Date between '" + dt.ToString("MM/dd/yyyy") + "' and '" + dt1.ToString("MM/dd/yyyy") + "' and hi.Hostel_Code=hd.Hostel_code and hi.Hostel_Code in('" + hostel + "')and hi.IncGroup_Code in('" + group + "')"; q1 = "select CONVERT(varchar(10), IncomeDate,103) as IncomeDate, hd.HostelName,hi.IncomeGroup,(select MasterValue from CO_MasterValues where MasterCode = ISNULL( hi.IncomeGroup,0)) as IncGroup_Code_txt,hi.IncomeAmount,hi.IncomeDesc from HT_HostelIncome hi,HM_HostelMaster hd where hd.HostelMasterPK=hi.HostelMasterFK and hi.IncomeDate between '" + dt.ToString("MM/dd/yyyy") + "' and '" + dt1.ToString("MM/dd/yyyy") + "' and hi.HostelMasterFK in('" + hostel + "')and hi.IncomeGroup in('" + group + "')";//and hd.collegecode='" + collegecode1 + "' } else { lbl_error1.Visible = false; q1 = "select CONVERT(varchar(10), IncomeDate,103) as IncomeDate, hd.HostelName,hi.IncomeGroup,(select MasterValue from CO_MasterValues where MasterCode = ISNULL( hi.IncomeGroup,0)) as IncGroup_Code_txt,SUM(hi.IncomeAmount)as IncomeAmount,hi.IncomeDesc from HT_HostelIncome hi,HM_HostelMaster hd where hd.HostelMasterPK=hi.HostelMasterFK and hi.HostelMasterFK in('" + hostel + "') and hi.IncomeGroup in('" + group + "') group by hi.IncomeGroup,hd.HostelName,hi.IncomeDesc,hi.IncomeDate";// } ds.Clear(); ds = d2.select_method_wo_parameter(q1, "Text"); if (ds.Tables[0].Rows.Count > 0) { Fpspread2.Sheets[0].RowCount = 0; Fpspread2.Sheets[0].ColumnCount = 0; Fpspread2.CommandBar.Visible = false; Fpspread2.Sheets[0].AutoPostBack = true; Fpspread2.Sheets[0].ColumnHeader.RowCount = 1; Fpspread2.Sheets[0].RowHeader.Visible = false; Fpspread2.Sheets[0].ColumnCount = 6; FarPoint.Web.Spread.StyleInfo darkstyle = new FarPoint.Web.Spread.StyleInfo(); darkstyle.BackColor = ColorTranslator.FromHtml("#0CA6CA"); darkstyle.ForeColor = Color.White; Fpspread2.ActiveSheetView.ColumnHeader.DefaultStyle = darkstyle; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 0].Text = "S.No"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 0].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 0].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 0].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 0].Font.Size = FontUnit.Medium; Fpspread2.Columns[0].Width = 50; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Hostel Name"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 1].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 1].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 1].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 1].Font.Size = FontUnit.Medium; Fpspread2.Columns[1].Width = 200; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Group Name"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 2].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 2].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 2].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 2].Font.Size = FontUnit.Medium; Fpspread2.Columns[2].Width = 100; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 3].Text = "Description"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 3].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 3].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 3].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 3].Font.Size = FontUnit.Medium; Fpspread2.Columns[3].Width = 200; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 4].Text = "Amount"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 4].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 4].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 4].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 4].Font.Size = FontUnit.Medium; Fpspread2.Columns[4].Width = 150; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 5].Text = "Date"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 5].Font.Bold = true; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 5].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 5].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].ColumnHeader.Cells[0, 5].Font.Size = FontUnit.Medium; Fpspread2.Columns[4].Width = 150; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Fpspread2.Sheets[0].RowCount++; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 0].Text = Convert.ToString(i + 1); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 0].HorizontalAlign = HorizontalAlign.Center; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 0].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 0].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 1].Text = Convert.ToString(ds.Tables[0].Rows[i]["HostelName"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 1].HorizontalAlign = HorizontalAlign.Left; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 1].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 1].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 2].Text = Convert.ToString(ds.Tables[0].Rows[i]["IncGroup_Code_txt"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 2].Tag = Convert.ToString(ds.Tables[0].Rows[i]["IncomeGroup"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 2].HorizontalAlign = HorizontalAlign.Left; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 2].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 2].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 3].Text = Convert.ToString(ds.Tables[0].Rows[i]["IncomeDesc"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 3].HorizontalAlign = HorizontalAlign.Left; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 3].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 3].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 4].Text = Convert.ToString(ds.Tables[0].Rows[i]["IncomeAmount"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 4].HorizontalAlign = HorizontalAlign.Right; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 4].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 4].Font.Name = "Book Antiqua"; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 5].Text = Convert.ToString(ds.Tables[0].Rows[i]["IncomeDate"]); Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 5].HorizontalAlign = HorizontalAlign.Right; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 5].Font.Size = FontUnit.Medium; Fpspread2.Sheets[0].Cells[Fpspread2.Sheets[0].RowCount - 1, 5].Font.Name = "Book Antiqua"; } Fpspread2.Sheets[0].PageSize = Fpspread2.Sheets[0].RowCount; Fpspread2.SaveChanges(); Fpspread2.Visible = true; rptprint.Visible = true; div2.Visible = true; lbl_error.Visible = false; } else { Fpspread2.Visible = false; div2.Visible = false; rptprint.Visible = false; lbl_error.Visible = true; lbl_error.Text = "No Record Found"; } } else { Fpspread2.Visible = false; rptprint.Visible = false; div2.Visible = false; lbl_error.Visible = true; lbl_error.Text = "Please Select All Field"; } } catch { } }