protected void btnupdate_Click(object sender, EventArgs e) { collierymaster objcolliery = new collierymaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); objcolliery.collierymaster_SRNO = -1; objcolliery.collierymaster_COLLIERYNAME = txtcollieryname.Text.Trim().ToString(); objcolliery.collierymaster_COLLIERYCODE = txtcollierycode.Text.Trim().ToString(); objcolliery.collierymaster_CMPID = General.Parse<int>(Session["cmpid"].ToString()); if (rdnagpur.Checked == true) { objcolliery.collierymaster_COLLIERYREGION = rdnagpur.Text.ToString(); } else if (rdwani.Checked == true) { objcolliery.collierymaster_COLLIERYREGION = rdwani.Text.ToString(); } objcolliery.collierymaster_STATUS = General.Parse<int>(ddlstatus.SelectedValue.ToString().Trim()); string condition = "SRNO=" + ViewState["COLLIERYID"].ToString().Trim(); if (objcolliery.Insert(false, "collierymaster", condition)) { if (coaltyperepeater.Items.Count > 0) { SqlConnection Connection = new SqlConnection("Data Source=50.28.62.129,1433;Network Library=DBMSSOCN;Initial Catalog=db_fuel;User ID=fuel;Password= lSa2@11h"); string qry = "delete from collierydetailmaster where collieryid=" + ViewState["COLLIERYID"].ToString(); Connection.Open(); SqlCommand com = new SqlCommand(qry, Connection); com.ExecuteNonQuery(); Connection.Close(); for (int i = 0; i < coaltyperepeater.Items.Count; i++) { CheckBox chkcoaltype = (CheckBox)coaltyperepeater.Items[i].FindControl("chkcoaltype"); if (chkcoaltype.Checked == true) { TextBox grade = (TextBox)coaltyperepeater.Items[i].FindControl("txtgrade"); TextBox notifiedfrice = (TextBox)coaltyperepeater.Items[i].FindControl("txtnotifiedprice"); TextBox commbenifitchg = (TextBox)coaltyperepeater.Items[i].FindControl("txtcommbenifitchrg"); TextBox crushing = (TextBox)coaltyperepeater.Items[i].FindControl("txtcrushingcharges"); TextBox stc = (TextBox)coaltyperepeater.Items[i].FindControl("txtstc"); TextBox sed = (TextBox)coaltyperepeater.Items[i].FindControl("txtsed"); TextBox cec = (TextBox)coaltyperepeater.Items[i].FindControl("txtcec"); TextBox royalty = (TextBox)coaltyperepeater.Items[i].FindControl("txtroyalty"); TextBox mprdtax = (TextBox)coaltyperepeater.Items[i].FindControl("txtmprdtax"); TextBox transit = (TextBox)coaltyperepeater.Items[i].FindControl("txttransitfee"); TextBox entry = (TextBox)coaltyperepeater.Items[i].FindControl("txtentryfee"); collierydetailmaster objdetails = new collierydetailmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); objdetails.collierydetailmaster_SRNO = -1; objdetails.collierydetailmaster_COALID = General.Parse<int>(chkcoaltype.CssClass.ToString().Trim()); objdetails.collierydetailmaster_COLLIERYID = General.Parse<int>(ViewState["COLLIERYID"].ToString().Trim()); objdetails.collierydetailmaster_GRADE = grade.Text.Trim().ToString(); objdetails.collierydetailmaster_NOTIFIEDPRICE = General.Parse<double>(notifiedfrice.Text.Trim().ToString()); objdetails.collierydetailmaster_COMMBENIFITCHARGES = General.Parse<double>(commbenifitchg.Text.Trim().ToString()); objdetails.collierydetailmaster_CRUSHINGCHARGES = General.Parse<double>(crushing.Text.Trim().ToString()); objdetails.collierydetailmaster_STC = General.Parse<double>(stc.Text.Trim().ToString()); objdetails.collierydetailmaster_SED = General.Parse<double>(sed.Text.Trim().ToString()); objdetails.collierydetailmaster_CEC = General.Parse<double>(cec.Text.Trim().ToString()); objdetails.collierydetailmaster_ROYALTY = General.Parse<double>(royalty.Text.Trim().ToString()); objdetails.collierydetailmaster_MPRDTAX = General.Parse<double>(mprdtax.Text.Trim().ToString()); objdetails.collierydetailmaster_TRANSITTAX = General.Parse<double>(transit.Text.Trim().ToString()); objdetails.collierydetailmaster_ENTRYFEE = General.Parse<double>(entry.Text.Trim().ToString()); objdetails.collierydetailmaster_STATUS = 0; if (objdetails.Insert(true, "collierydetailmaster")) { } } } Response.Redirect("collierylist.aspx?ID=1"); } } }
protected void btnsubmit_Click(object sender, EventArgs e) { Handler hdnpartycode=new Handler(); DataTable dtpartycode = hdnpartycode.GetTable("SELECT SRNO FROM COLLIERYMASTER PM WHERE STATUS=0 AND COLLIERYCODE='" + txtcollierycode.Text.Trim().ToString() + "'"); if (dtpartycode.Rows.Count == 0) { collierymaster objcolliery = new collierymaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); objcolliery.collierymaster_SRNO = -1; objcolliery.collierymaster_COLLIERYNAME = txtcollieryname.Text.Trim().ToString(); objcolliery.collierymaster_COLLIERYCODE = txtcollierycode.Text.Trim().ToString(); objcolliery.collierymaster_CMPID = General.Parse<int>(Session["cmpid"].ToString()); if (rdnagpur.Checked == true) { objcolliery.collierymaster_COLLIERYREGION = rdnagpur.Text.ToString(); } else if (rdwani.Checked == true) { objcolliery.collierymaster_COLLIERYREGION = rdwani.Text.ToString(); } objcolliery.collierymaster_STATUS = 0; if (objcolliery.Insert(true, "collierymaster")) { string sqlmax = "SELECT MAX(CM.SRNO) FROM collierymaster CM WHERE STATUS=0 AND COLLIERYNAME='" + txtcollieryname.Text.ToString().Trim() + "'"; Handler hdnmax = new Handler(); DataTable dtmax = hdnmax.GetTable(sqlmax); if (dtmax.Rows.Count > 0 && coaltyperepeater.Items.Count > 0) { for (int i = 0; i < coaltyperepeater.Items.Count; i++) { CheckBox chkcoaltype = (CheckBox)coaltyperepeater.Items[i].FindControl("chkcoaltype"); if (chkcoaltype.Checked == true) { TextBox grade = (TextBox)coaltyperepeater.Items[i].FindControl("txtgrade"); TextBox notifiedfrice = (TextBox)coaltyperepeater.Items[i].FindControl("txtnotifiedprice"); TextBox commbenifitchg = (TextBox)coaltyperepeater.Items[i].FindControl("txtcommbenifitchrg"); TextBox crushing = (TextBox)coaltyperepeater.Items[i].FindControl("txtcrushingchg"); TextBox stc = (TextBox)coaltyperepeater.Items[i].FindControl("txtstc"); TextBox sed = (TextBox)coaltyperepeater.Items[i].FindControl("txtsed"); TextBox cec = (TextBox)coaltyperepeater.Items[i].FindControl("txtroyalty"); TextBox royalty = (TextBox)coaltyperepeater.Items[i].FindControl("txtcec"); TextBox mprdtax = (TextBox)coaltyperepeater.Items[i].FindControl("txtmprdtax"); TextBox transit = (TextBox)coaltyperepeater.Items[i].FindControl("txttransitfee"); TextBox entry = (TextBox)coaltyperepeater.Items[i].FindControl("txtentryfee"); collierydetailmaster objdetails = new collierydetailmaster(HttpContext.Current.Server.MapPath("~/XML/database.xml")); objdetails.collierydetailmaster_SRNO = -1; objdetails.collierydetailmaster_COALID = General.Parse<int>(chkcoaltype.CssClass.ToString().Trim()); objdetails.collierydetailmaster_COLLIERYID = General.Parse<int>(dtmax.Rows[0][0].ToString()); objdetails.collierydetailmaster_GRADE = grade.Text.Trim().ToString(); objdetails.collierydetailmaster_NOTIFIEDPRICE = General.Parse<double>(notifiedfrice.Text.Trim().ToString()); objdetails.collierydetailmaster_COMMBENIFITCHARGES = General.Parse<double>(commbenifitchg.Text.Trim().ToString()); objdetails.collierydetailmaster_CRUSHINGCHARGES = General.Parse<double>(crushing.Text.Trim().ToString()); objdetails.collierydetailmaster_STC = General.Parse<double>(stc.Text.Trim().ToString()); objdetails.collierydetailmaster_SED = General.Parse<double>(sed.Text.Trim().ToString()); objdetails.collierydetailmaster_CEC = General.Parse<double>(cec.Text.Trim().ToString()); objdetails.collierydetailmaster_ROYALTY = General.Parse<double>(royalty.Text.Trim().ToString()); objdetails.collierydetailmaster_MPRDTAX = General.Parse<double>(mprdtax.Text.Trim().ToString()); objdetails.collierydetailmaster_TRANSITTAX = General.Parse<double>(transit.Text.Trim().ToString()); objdetails.collierydetailmaster_ENTRYFEE = General.Parse<double>(entry.Text.Trim().ToString()); objdetails.collierydetailmaster_STATUS = 0; if (objdetails.Insert(true, "collierydetailmaster")) { } } } //Response.Redirect("collierydetails.aspx?ID=1&COLLIERYID=" + dtmax.Rows[0][0].ToString()); Response.Redirect("collierylist.aspx?ID=2"); } } } else { MessageBox("Colliery Code Already Present"); } }