protected void btnChnageStatsu_OnClick(object sender, EventArgs e) { try { FeeMaster fmcls = new FeeMaster(); dtinfo.DateSeparator = "/"; dtinfo.ShortDatePattern = "dd/MM/yyyy"; con.Close(); con.Open(); SqlCommand cmd = new SqlCommand(); if (lblStatus2.Text == "Disactive") { btnchangeStatus.Text = "Active"; strstatus = "yes"; } else if (lblStatus2.Text == "Active") { btnchangeStatus.Text = "Disactive"; strstatus = "no"; } if (lblStatus2.Text == "New Registration") { cmd = new SqlCommand("select Status from IMInspection where ID='" + lblID.Text.ToString() + "'", con); string insp = Convert.ToString(cmd.ExecuteScalar()); if (insp == "") { lblExceptionActive.Text = "Inspection Report Not Submitted Yet."; } else if (insp == "NotApprove" || insp == "NotApproved") { lblExceptionActive.Text = "Inspection Status is " + insp.ToString(); } if (lblMemberTyep.Text != "IM") { insp = "Approve"; } if (insp == "Approve" || insp == "SubToApprove") { if (chkAC(Convert.ToInt32(lblSubFee.Text) + Convert.ToInt32(lblEnrollFee.Text), Convert.ToInt32(lblBalance.Text), lblBalanceType.Text)) { string gid = genid(); if (lblMemberTyep.Text == "IM") { SqlCommand cmdx = new SqlCommand("update IM set ID=@ID, Active=@Active where ID='" + lblID.Text.ToString() + "'", con); cmdx.Parameters.AddWithValue("@ID", gid.ToString()); cmdx.Parameters.AddWithValue("@Active", "no"); cmdx.ExecuteNonQuery(); cmd = new SqlCommand("update IMAC set IMID=@IMID where IMID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@IMID", gid.ToString()); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update IMInspection set ID=@ID where ID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@ID", gid.ToString()); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update Account set IMID=@ID where IMID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@ID", gid.ToString()); cmd.ExecuteNonQuery(); } cmd = new SqlCommand("update FeeAC set IMID=@ID where IMID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@ID", gid.ToString()); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update Member set ID=@ID,Active=@Active,YearFrom=@YearFrom, YearTo=@YearTo where ID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@Active", "no"); cmd.Parameters.AddWithValue("@ID", gid.ToString()); cmd.Parameters.AddWithValue("@YearFrom", ddlSessionFrom.SelectedValue.ToString() + "" + txtYearFrom.Text.ToString()); cmd.Parameters.AddWithValue("@YearTo", fmcls.nextSession(ddlSessionFrom.SelectedValue.ToString() + "" + txtYearFrom.Text.ToString())); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update MemberFee set ID=@ID where ID='" + lblID.Text.ToString() + "'", con); cmd.Parameters.AddWithValue("@ID", gid.ToString()); cmd.ExecuteNonQuery(); cmd = new SqlCommand("Update IMBooks set IMID='" + gid + "' where IMID='" + lblID.Text.ToString() + "'", con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update IMStock set IMID='" + gid + "' where IMID='" + lblID.Text.ToString() + "'", con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update DiaryEntry set IMID='" + gid.ToString() + "', MembershipNo='" + gid.ToString() + "' where IMID='" + lblID.Text.ToString() + "'", con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("update DairyCount set IMID='" + gid.ToString() + "' where IMID='" + lblID.Text.ToString() + "'", con); cmd.ExecuteNonQuery(); btnchangeStatus.Text = "New ID: " + gid.ToString(); lblID.Text = gid.ToString(); lblStatus2.Text = "Disactive"; lblExceptionActive.Text = "Membership ID: " + gid.ToString(); txtIMID.Text = gid.ToString(); imtrans(txtIMID.Text.ToString(), lblEnrollFee.Text.ToString(), "Membership Fees", "Membership"); imtrans(txtIMID.Text.ToString(), lblSubFee.Text.ToString(), "Subscription Fees", "Subscription"); amountupdate(txtIMID.Text.ToString(), Convert.ToInt32(lblEnrollFee.Text)); amountupdate(txtIMID.Text.ToString(), Convert.ToInt32(lblSubFee.Text)); Response.Redirect(System.Web.HttpContext.Current.Request.Url.AbsolutePath.ToString() + "?name=" + Request.QueryString["name"] + "&lnk=" + Request.QueryString["lnk"] + "&typ=" + Request.QueryString["typ"] + "&lvl=" + Request.QueryString["lvl"] + "&id=" + txtIMID.Text.ToString()); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Not Enough Amount Found.')", true); } } } else { cmd = new SqlCommand("update Member set Active='" + strstatus.ToString() + "' where ID='" + txtIMID.Text.ToString() + "'", con); cmd.ExecuteNonQuery(); con.Close(); if (strstatus == "yes") { btnchangeStatus.Text = "Disactive"; lblStatus2.Text = "Active"; lblExceptionActive.Text = "Membership Activeted"; } else { btnchangeStatus.Text = "Active"; lblStatus2.Text = "Disactive"; lblExceptionActive.Text = "Membership Disactiveted"; } } } catch (Exception ex) { lblExceptionActive.Text = "Amount Not Found."; } finally { btnchangeStatus.Focus(); } }
public void imtrans(string imid, string amt, string feetype, string stype) { con.Close(); con.Open(); int tid; int bl, fee, dif = 0; string ttype; SqlCommand cmd2 = new SqlCommand(); try { cmd2 = new SqlCommand("select max(TransID) from MemberFee where ID='" + imid.ToString() + "'", con); tid = Convert.ToInt32(cmd2.ExecuteScalar()); if (tid == null) { bl = 0; tid = 0; ttype = "Credit"; } } catch (InvalidCastException ex) { bl = 0; tid = 0; ttype = "Credit"; } cmd2 = new SqlCommand("select TransType from MemberFee Where ID='" + imid.ToString() + "' and TransID='" + tid + "'", con); ttype = Convert.ToString(cmd2.ExecuteScalar()); if (ttype == "" && tid == 0) { ttype = "Credit"; } bl = Convert.ToInt32(lblBalance.Text); fee = Convert.ToInt32(amt); if (ttype == "Debit") { dif = fee + bl; ttype = "Debit"; } else if (ttype == "Credit") { if (bl >= fee) { dif = bl - fee; ttype = "Credit"; } else { dif = fee - bl; ttype = "Debit"; } } dtinfo.ShortDatePattern = "dd/MM/yyyy"; dtinfo.DateSeparator = "/"; tid += 1; cmd2 = new SqlCommand("insert into MemberFee (MType, ID, Amt, FeeType, SubDate, SubType, AcountNo, DD, Bank, YearFrom, YearTo,TransType,Balance,TransID) values(@MType, @ID, @Amt, @FeeType, @SubDate, @SubType, @AcountNo, @DD, @Bank, @YearFrom, @YearTo, @TransType, @Balance,@TransID)", con); cmd2.Parameters.AddWithValue("@MType", lblMemberTyep.Text.ToString()); cmd2.Parameters.AddWithValue("@ID", imid.ToString()); cmd2.Parameters.AddWithValue("@Amt", amt.ToString()); cmd2.Parameters.AddWithValue("@FeeType", feetype.ToString()); cmd2.Parameters.AddWithValue("@SubDate", Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy"), dtinfo)); cmd2.Parameters.AddWithValue("@SubType", stype.ToString()); cmd2.Parameters.AddWithValue("@AcountNo", "N/A"); cmd2.Parameters.AddWithValue("@DD", "N/A"); cmd2.Parameters.AddWithValue("@Bank", "N/A"); cmd2.Parameters.AddWithValue("@YearFrom", ddlSessionFrom.SelectedValue.ToString() + "" + txtYearFrom.Text.ToString()); cmd2.Parameters.AddWithValue("@YearTo", fmcls.nextSession(ddlSessionFrom.SelectedValue.ToString() + "" + txtYearFrom.Text.ToString())); cmd2.Parameters.AddWithValue("@TransType", ttype.ToString()); cmd2.Parameters.AddWithValue("@Balance", dif.ToString()); cmd2.Parameters.AddWithValue("@TransID", tid); cmd2.ExecuteNonQuery(); lblBalanceType.Text = ttype.ToString(); lblBalance.Text = dif.ToString(); ClsAccount cl = new ClsAccount(); cl.AmountSubmit(imid, "", DateTime.Now, "Debit", amt, lblSessionHiddend.Text.ToString(), feetype); con.Close(); }
private void showprofile(string id) { try { dtinfo.ShortDatePattern = "dd/MM/yyyy"; dtinfo.DateSeparator = "/"; con.Close(); con.Open(); cmd = new SqlCommand("select Name from Member where ID='" + id.ToString() + "'", con); string chkexist = Convert.ToString(cmd.ExecuteScalar()); if (chkexist == "") { //lblException.Text = "Invalid Membership No." + txtIMID.Text.ToString(); txtIMID.Text = ""; panelProfile.Visible = false; panelChangeStatus.Visible = false; panelSubscribe.Visible = false; txtIMID.Focus(); } else { SqlDataReader reader; cmd = new SqlCommand("select max(TransID) from MemberFee where ID='" + id.ToString() + "'", con); string tid = Convert.ToString(cmd.ExecuteScalar()); if (tid == "") { tid = "0"; lblBalance.Text = "0"; lblBalanceType.Text = ""; } else { cmd = new SqlCommand("select TransType, Balance from MemberFee where ID='" + id.ToString() + "' and TransID='" + Convert.ToInt32(tid.ToString()) + "'", con); reader = cmd.ExecuteReader(); while (reader.Read()) { lblBalanceType.Text = reader["TransType"].ToString(); lblBalance.Text = reader["Balance"].ToString().TrimEnd('0').TrimEnd('.'); } reader.Close(); } panelProfile.Visible = true; panelChangeStatus.Visible = true; panelSubscribe.Visible = true; cmd = new SqlCommand("select * from Member where ID='" + id.ToString() + "'", con); reader = cmd.ExecuteReader(); while (reader.Read()) { lblName.Text = reader[3].ToString(); lblMemberTyep.Text = reader["Type"].ToString(); lblID.Text = reader[2].ToString(); lblAddress.Text = reader[7].ToString(); lblCity.Text = reader["Address2"].ToString() + ", " + reader[8].ToString(); lblEmail.Text = reader[14].ToString(); lblPhonne.Text = reader[10].ToString(); lblMobile.Text = reader[13].ToString(); string sts = reader[71].ToString(); if (sts.ToString() == "yes" | sts.ToString() == "Active") { lblStatus2.Text = "Active"; btnchangeStatus.Text = "Disactive"; } else if (sts.ToString() == "Register" | sts.ToString() == "Registered") { lblStatus2.Text = "New Registration"; btnchangeStatus.Text = "Generate Membership"; } else { lblStatus2.Text = "Disactive"; btnchangeStatus.Text = "Active"; } lblEnrollDate.Text = Convert.ToDateTime(reader[72].ToString()).ToString("dd/MM/yyyy"); lblRenuwalDate.Text = Convert.ToDateTime(reader[73].ToString()).ToString("dd/MM/yyyy"); lblExpDate.Text = Convert.ToDateTime(reader[74].ToString()).ToString("dd/MM/yyyy"); lblfrom.Text = reader[75].ToString(); lblTo.Text = reader[76].ToString(); } reader.Close(); GridBalance.DataSource = GridBalanceData(id); GridBalance.DataBind(); getFee(); FeeMaster fm = new FeeMaster(); lblSubscriptionFrom.Text = fm.nextSession(lblTo.Text); lblSubscriptionTo.Text = fm.nextSession(lblSubscriptionFrom.Text.ToString()); } } catch (SqlException ex) { panelProfile.Visible = false; panelChangeStatus.Visible = false; panelSubscribe.Visible = false; } finally { con.Close(); } }