private void listSub_Click(object sender, EventArgs e) { clsSLBAL SlBAL = new clsSLBAL(); clsSLBO SlBO = new clsSLBO(); //string crt = "GLID"; SlBO = SlBAL.GetValue(Convert.ToString(listSub.SelectedValue)); txtID.Text = SlBO.GetSLID(); txtDesc.Text = SlBO.GetSL_L_NAME(); txtAdd1.Text = SlBO.GetSLADD1(); txtAdd2.Text = SlBO.GetSLADD2(); txtCity.Text = SlBO.GetSLCITY(); txtPin.Text = SlBO.GetSLPIN(); txtPhone.Text = SlBO.GetSLPHONE(); txtFax.Text = SlBO.GetSLFAX(); txtContact.Text = SlBO.GetSLCONT_PERS(); txtRem.Text = SlBO.GetREMARKS(); txtOpen.Text = Convert.ToString(Math.Abs(SlBO.Getop_bal())); textBox1.Text = SlBO.Getgstin(); if (SlBO.Getop_bal() >= 0) { radioButton1.Checked = true; //cmbOpenType.Text = "Dr"; } else { radioButton2.Checked = true; //cmbOpenType.Text = "Cr"; } if (Convert.ToString(SlBO.GetGLID()) == "00004" || Convert.ToString(SlBO.GetGLID()) == "00003") { if (Convert.ToString(SlBO.GetSTATUS()) == "G") { cmbType.Text = "General"; } else if (Convert.ToString(SlBO.GetSTATUS()) == "C") { cmbType.Text = "Customer"; } else if (Convert.ToString(SlBO.GetSTATUS()) == "S") { cmbType.Text = "Supplier"; } } if (SlBO.GetSL_L_NAME() != "") { btnSave.Text = "&Update"; } else { btnSave.Text = "&Save"; } }
public clsSLBO GetValue(string vSLID) { clsSLBO SlBO = new clsSLBO(); SqlCommand cmd = new SqlCommand(); SqlDataReader Sread; //Double tmp_op_bal = 0; cmd.CommandText = "select Finyr,BrCode,GLID,SLID,SL_L_NAME,SLADD1,SLADD2,SLCITY,SLPIN,SLFAX,SLPHONE,SLCONT_PERS,REMARKS,OP_BAL,STATUS,GSTIN from TblSLMast Where SLID = '" + vSLID + "' and finyr='" + Global.finyr + "' and BrCode='" + Global.branch + "' order by SL_L_Name"; cmd.Connection = clsConnection.Conn; Sread = cmd.ExecuteReader(); while (Sread.Read()) { if (!Sread.IsDBNull(0)) { //tmp_op_bal = Convert.ToDouble(string.IsNullOrEmpty(Sread.GetValue(13).ToString()) ? 0 : Sread.GetValue(13)); SlBO.SetValue(Convert.ToString(Sread.GetValue(0)), Convert.ToString(Sread.GetValue(1)), Convert.ToString(Sread.GetValue(2)), Convert.ToString(Sread.GetValue(3)), Convert.ToString(Sread.GetValue(4)), Convert.ToString(Sread.GetValue(5)), Convert.ToString(Sread.GetValue(6)), Convert.ToString(Sread.GetValue(7)), Convert.ToString(Sread.GetValue(8)), Convert.ToString(Sread.GetValue(9)), Convert.ToString(Sread.GetValue(10)), Convert.ToString(Sread.GetValue(11)), Convert.ToString(Sread.GetValue(12)), Convert.ToDouble(string.IsNullOrEmpty(Sread.GetValue(13).ToString()) ? 0 : Sread.GetValue(13)), Convert.ToString(Sread.GetValue(14)), Convert.ToString(Sread.GetValue(15))); } } Sread.Close(); cmd.Dispose(); return(SlBO); }
public String SaveData(clsSLBO SlBO) { SqlCommand cmd = new SqlCommand(); String Result; cmd.CommandText = "Insert into TblSLMast(Finyr,BrCode,GLID,SLID,SL_L_NAME,SLADD1,SLADD2,SLCITY,SLPIN,SLFAX,SLPHONE,SLCONT_PERS,REMARKS,OP_BAL,STATUS,GSTIN)" + "Values(@Finyr,@BrCode,@GLID,@SLID,@SL_L_NAME,@SLADD1,@SLADD2,@SLCITY,@SLPIN,@SLFAX,@SLPHONE,@SLCONT_PERS,@REMARKS,@OP_BAL,@STATUS,@GSTIN)"; cmd.Connection = clsConnection.Conn; try { cmd.Parameters.AddWithValue("@Finyr", SlBO.Getfinyr()); cmd.Parameters.AddWithValue("@BrCode", SlBO.GetBrCode()); cmd.Parameters.AddWithValue("@GLID", SlBO.GetGLID()); cmd.Parameters.AddWithValue("@SLID", SlBO.GetSLID()); cmd.Parameters.AddWithValue("@SL_L_NAME", SlBO.GetSL_L_NAME()); cmd.Parameters.AddWithValue("@SLADD1", SlBO.GetSLADD1()); cmd.Parameters.AddWithValue("@SLADD2", SlBO.GetSLADD2()); cmd.Parameters.AddWithValue("@SLCITY", SlBO.GetSLCITY()); cmd.Parameters.AddWithValue("@SLPIN", SlBO.GetSLPIN()); cmd.Parameters.AddWithValue("@SLFAX", SlBO.GetSLFAX()); cmd.Parameters.AddWithValue("@SLPHONE", SlBO.GetSLPHONE()); cmd.Parameters.AddWithValue("@SLCONT_PERS", SlBO.GetSLCONT_PERS()); cmd.Parameters.AddWithValue("@REMARKS", SlBO.GetREMARKS()); cmd.Parameters.AddWithValue("@op_bal", SlBO.Getop_bal()); cmd.Parameters.AddWithValue("@STATUS", SlBO.GetSTATUS()); cmd.Parameters.AddWithValue("@GSTIN", SlBO.Getgstin()); cmd.ExecuteNonQuery(); Result = "Record Inserted Successfully"; } catch (Exception) { //Logger.LogInfo(ex); //Logger.LogInfo("Patient Registration failed"); Result = "Please check all Inputs"; } cmd.Dispose(); return(Result); }
public string UpdateData(clsSLBO SlBO) { SqlCommand cmd = new SqlCommand(); String Result; cmd.CommandText = "Update TblSLMast set SL_L_NAME=@SL_L_NAME,SLADD1=@SLADD1,SLADD2=@SLADD2,SLCITY=@SLCITY,SLPIN=@SLPIN,SLFAX=@SLFAX,SLPHONE=@SLPHONE,SLCONT_PERS=@SLCONT_PERS,REMARKS=@REMARKS,OP_BAL=@OP_BAL,STATUS=@STATUS,GSTIN=@GSTIN where SLID = '" + SlBO.GetSLID() + "' and BrCode='" + Global.branch + "' and finyr='" + Global.finyr + "'"; cmd.Connection = clsConnection.Conn; try { cmd.Parameters.AddWithValue("@Finyr", SlBO.Getfinyr()); cmd.Parameters.AddWithValue("@BrCode", SlBO.GetBrCode()); cmd.Parameters.AddWithValue("@GLID", SlBO.GetGLID()); cmd.Parameters.AddWithValue("@SLID", SlBO.GetSLID()); cmd.Parameters.AddWithValue("@SL_L_NAME", SlBO.GetSL_L_NAME()); cmd.Parameters.AddWithValue("@SLADD1", SlBO.GetSLADD1()); cmd.Parameters.AddWithValue("@SLADD2", SlBO.GetSLADD2()); cmd.Parameters.AddWithValue("@SLCITY", SlBO.GetSLCITY()); cmd.Parameters.AddWithValue("@SLPIN", SlBO.GetSLPIN()); cmd.Parameters.AddWithValue("@SLFAX", SlBO.GetSLFAX()); cmd.Parameters.AddWithValue("@SLPHONE", SlBO.GetSLPHONE()); cmd.Parameters.AddWithValue("@SLCONT_PERS", SlBO.GetSLCONT_PERS()); cmd.Parameters.AddWithValue("@REMARKS", SlBO.GetREMARKS()); cmd.Parameters.AddWithValue("@op_bal", SlBO.Getop_bal()); cmd.Parameters.AddWithValue("@STATUS", SlBO.GetSTATUS()); cmd.Parameters.AddWithValue("@GSTIN", SlBO.Getgstin()); cmd.ExecuteNonQuery(); Result = "Record Updated Successfully"; } catch (Exception ex) { Result = ex.Message; } cmd.Dispose(); return(Result); }
private void FillData() { clsGLBAL GlBAL = new clsGLBAL(); clsGLBO GlBO = new clsGLBO(); clsSLBAL SlBAL = new clsSLBAL(); clsSLBO SlBO = new clsSLBO(); dataGridView1.Columns["Debit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns["Credit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DataGridViewCellStyle style = new DataGridViewCellStyle(); style.Font = new Font(dataGridView1.Font, FontStyle.Bold); dataGridView1.Columns["Date"].DefaultCellStyle.Font = style.Font; dataGridView1.Columns["Type"].DefaultCellStyle.Font = style.Font; dataGridView1.Columns["VNO"].DefaultCellStyle.Font = style.Font; //Date //Type //VNo //Particular //Debit //Credit //Glid //Slid //TrnType //V_No string QRY = ""; if (listBox1.SelectedIndex != 0) { QRY = "Select * from LedgerView where BrCode='" + Global.branch + "' and TranType='" + vtype_list1 + "' and VDT>='" + dtpFrom.Value.ToString("dd/MM/yyyy") + "' and VDT<'" + dtpTo.Value.AddDays(1).ToString("dd/MM/yyyy") + "' order by VDT, TranType, Vno"; } else { QRY = "Select * from LedgerView where BrCode='" + Global.branch + "'and VDT>='" + dtpFrom.Value.ToString("dd/MM/yyyy") + "' and VDT<'" + dtpTo.Value.AddDays(1).ToString("dd/MM/yyyy") + "' order by VDT, TranType, Vno"; } SqlDataAdapter da = new SqlDataAdapter(QRY, clsConnection.Conn); DataSet ds = new DataSet(); if (ds.Tables["DayBook"] != null) { ds.Tables["DayBook"].Clear(); } da.Fill(ds, "DayBook"); DataTable dt = ds.Tables["DayBook"]; string lastvno = ""; string lastvdt = ""; string lastvtype = ""; Int32 i = 0; foreach (DataRow row in dt.Rows) { dataGridView1.Rows.Add(); if (lastvno == Convert.ToString(row["VNO"]) && lastvdt == Convert.ToString(row["VDT"]) && lastvtype == Convert.ToString(row["TRANTYPE"])) { i = i + 1; } else { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Date"].Value = Convert.ToDateTime(row["VDT"]).ToString("dd/MM/yyyy"); if (Convert.ToString(row["TRANTYPE"]) == "Y") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Payment"; } else if (Convert.ToString(row["TRANTYPE"]) == "R") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Receipt"; } else if (Convert.ToString(row["TRANTYPE"]) == "J") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Journal"; } else if (Convert.ToString(row["TRANTYPE"]) == "T") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Contra"; } else if (Convert.ToString(row["TRANTYPE"]) == "P") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Purchase"; } else if (Convert.ToString(row["TRANTYPE"]) == "S") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Type"].Value = "Sale"; } dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["VNo"].Value = Convert.ToString(row["VNO"]); } if ((string.IsNullOrEmpty(row["SLID"].ToString()) ? "" : row["SLID"].ToString()) == "" || row["SLID"].ToString() == "0" || row["SLID"].ToString() == "00") { GlBO = GlBAL.GetValue(Convert.ToString(row["GLID"])); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Particular"].Value = GlBO.GetGL_L_NAME(); } else { SlBO = SlBAL.GetValue(Convert.ToString(row["SLID"])); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Particular"].Value = SlBO.GetSL_L_NAME(); //Convert.ToString(row["SL_L_NAME"]); } if (Convert.ToString(row["AMTTYPE"]) == "D") { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Debit"].Value = Math.Round(Convert.ToDouble(row["AMT"]), 2); } else { dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Credit"].Value = Math.Round(Convert.ToDouble(row["AMT"]), 2); } dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Glid"].Value = Convert.ToString(row["GLID"]); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["Slid"].Value = (string.IsNullOrEmpty(row["SLID"].ToString()) ? "" : row["SLID"]); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["TrnType"].Value = Convert.ToString(row["TRANTYPE"]); dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells["V_NO"].Value = Convert.ToString(row["VNO"]); lastvno = Convert.ToString(row["VNO"]); lastvdt = Convert.ToString(row["VDT"]); lastvtype = Convert.ToString(row["TRANTYPE"]); } }