protected void chkactive_chachedChanged(object sender, EventArgs e) { GridViewRow row = ((CheckBox)sender).Parent.Parent as GridViewRow; int rinrow = row.RowIndex; ViewState["id"] = Convert.ToString(grd.DataKeys[rinrow].Value); Label lblWhid = (Label)grd.Rows[rinrow].FindControl("lblWhid"); Label lblEndd = (Label)grd.Rows[rinrow].FindControl("lbledate"); ViewState["Whid"] = lblWhid.Text; string openingdate = "select StartDate,EndDate,Report_Period_Id from ReportPeriod where Compid='" + Session["Comid"].ToString() + "' and Whid='" + ViewState["Whid"] + "' and Active='1'"; SqlCommand cmd22221 = new SqlCommand(openingdate, con); SqlDataAdapter adp22221 = new SqlDataAdapter(cmd22221); DataTable ds112221 = new DataTable(); adp22221.Fill(ds112221); if (ds112221.Rows.Count > 0) { ViewState["CurrentActiveStartDate"] = ds112221.Rows[0]["StartDate"].ToString(); ViewState["CurrentActiveEndDate"] = ds112221.Rows[0]["EndDate"].ToString(); ViewState["RPACT"] = ds112221.Rows[0]["EndDate"].ToString(); } string str1 = "select Name,Report_Period_Id,StartDate,EndDate from ReportPeriod where EndDate='" + lblEndd.Text + "' and Whid='" + ViewState["Whid"] + "'"; SqlCommand cmd1 = new SqlCommand(str1); cmd1.Connection = con; SqlDataAdapter da1 = new SqlDataAdapter(); da1.SelectCommand = cmd1; DataTable ds1 = new DataTable(); da1.Fill(ds1); if (ds1.Rows.Count > 0) { ViewState["SelectedYearStartDate"] = ds1.Rows[0]["StartDate"].ToString(); ViewState["SelectedYearEndDate"] = ds1.Rows[0]["EndDate"].ToString(); ViewState["id"] = ds1.Rows[0]["Report_Period_Id"].ToString(); } DateTime dt = Convert.ToDateTime(ViewState["CurrentActiveEndDate"]); DateTime dt2 = dt.AddYears(1); DateTime dt3 = dt.AddYears(-1); DateTime dtnewdate = Convert.ToDateTime(ViewState["SelectedYearEndDate"]); if (dtnewdate == dt2 || dtnewdate == dt3) { ModalPopupExtender122.Show(); } else { ModalPopupExtender1.Show(); } }
protected void btns_Click(object sender, EventArgs e) { lblmsg.Text = ""; if (ddlbusiness.SelectedIndex > -1) { btnaddnewaccount0.Visible = true; } else { btnaddnewaccount0.Visible = false; } fillgrid(); ModalPopupExtender122.Hide(); }
protected void btnconf_Click(object sender, EventArgs e) { ModalPopupExtender122.Show(); }
protected void btnapd_Click(object sender, EventArgs e) { int Currentyearorg = 0; int Currentyear = 0; DataTable dtda = (DataTable)select("select Report_Period_Id,Convert(nvarchar,StartDate,101) as StartDate, Convert(nvarchar,EndDate,101) as EndDate from [ReportPeriod] where Compid = '" + Session["comid"] + "' and Whid='" + ddlbus.SelectedValue + "' and Active='1' "); if (dtda.Rows.Count > 0) { DataTable dtdaopb = new DataTable(); dtdaopb = (DataTable)select("select top(1)Report_Period_Id from [ReportPeriod] where ReportPeriod.Report_Period_Id<'" + dtda.Rows[0]["Report_Period_Id"] + "' and Whid='" + ddlbus.SelectedValue + "' order by Report_Period_Id Desc"); if (dtdaopb.Rows.Count > 0) { string inse = "Insert into Report_period_confirm(Report_Period_Id,conform)values('" + dtda.Rows[0]["Report_Period_Id"] + "','1')"; SqlCommand cmd = new SqlCommand(inse, con); if (con.State.ToString() != "Open") { con.Open(); } cmd.ExecuteNonQuery(); con.Close(); Currentyear = Convert.ToInt32(ddlacyear.SelectedItem.Text) + 1; Currentyearorg = DateTime.Now.Year + 1; int yem = Convert.ToInt32(ddlacyear.SelectedItem.Text) + 1; string yname = ddlacyear.SelectedItem.Text + " TO " + yem.ToString(); string upd = "Update ReportPeriod set Name='" + yname + "',StartDate='" + Convert.ToDateTime(lblfysdate.Text) + "',EndDate='" + Convert.ToDateTime(lblfyedate.Text) + "',FistStartDate='" + Convert.ToDateTime(lblfysdate.Text) + "' where Report_Period_Id='" + dtda.Rows[0]["Report_Period_Id"] + "'"; SqlCommand cmd1 = new SqlCommand(upd, con); if (con.State.ToString() != "Open") { con.Open(); } cmd1.ExecuteNonQuery(); con.Close(); int yem1 = Convert.ToInt32(ddlacyear.SelectedItem.Text) - 1; string yname1 = yem1.ToString() + " TO " + ddlacyear.SelectedItem.Text; string upd1 = "Update ReportPeriod set Name='" + yname1 + "',StartDate='" + Convert.ToDateTime(lblfysdate.Text).AddYears(-1).ToString() + "',EndDate='" + Convert.ToDateTime(lblfyedate.Text).AddYears(-1).ToString() + "',FistStartDate='" + Convert.ToDateTime(lblfysdate.Text) + "' where Report_Period_Id='" + dtdaopb.Rows[0]["Report_Period_Id"] + "'"; SqlCommand cmd11 = new SqlCommand(upd1, con); if (con.State.ToString() != "Open") { con.Open(); } cmd11.ExecuteNonQuery(); con.Close(); int k = 1; for (int i = Currentyear; i < Currentyearorg; i++) { DateTime fye = Convert.ToDateTime(lblfysdate.Text).AddYears(k); DateTime eye = Convert.ToDateTime(lblfyedate.Text).AddYears(k); int sy = Convert.ToInt32(ddlacyear.SelectedItem.Text) + k; int ey = Convert.ToInt32(ddlacyear.SelectedItem.Text) + (k + 1); string nam = sy.ToString() + " TO " + ey.ToString(); SqlCommand cmdtr2 = new SqlCommand("Insert into ReportPeriod(Name,StartDate,EndDate,FistStartDate,Active,Compid,Whid)Values('" + nam + "','" + fye + "','" + eye + "','" + fye + "','0','" + Session["Comid"] + "','" + ddlbus.SelectedValue + "') ", con); if (con.State.ToString() != "Open") { con.Open(); } cmdtr2.ExecuteNonQuery(); con.Close(); k += 1; SqlCommand cmsa = new SqlCommand("SELECT max(Report_Period_Id) from ReportPeriod where Compid='" + Session["comid"] + "' and Whid='" + ddlbus.SelectedValue + "'", con); con.Open(); object rig = cmsa.ExecuteScalar(); con.Close(); string str5t1 = "select Id from AccountMaster where Whid='" + ddlbus.SelectedValue + "'"; SqlCommand cmd32t1 = new SqlCommand(str5t1, con); SqlDataAdapter adp15t1 = new SqlDataAdapter(cmd32t1); DataTable dtlogin14t1 = new DataTable(); adp15t1.Fill(dtlogin14t1); foreach (DataRow dr in dtlogin14t1.Rows) { SqlCommand cmdtr13 = new SqlCommand("Insert into AccountBalance(AccountMasterId,Balance,Report_Period_Id)Values('" + dr["Id"] + "','0','" + rig + "') ", con); con.Open(); cmdtr13.ExecuteNonQuery(); con.Close(); } } contr(false); ModalPopupExtender122.Hide(); } } }