public clsInstallmentPlan GetInstallmentPlanById(int id)
        {
            clsInstallmentPlan info = new clsInstallmentPlan();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand("TMR_USP_GetInstallmentPlanById"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = conn;

                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        info.strInstallmentPlanName = reader["InstallmentPlanName"].ToString();
                        info.bInactive             = Convert.ToBoolean(reader["Inactive"]);
                        info.strIntallmentPlanCode = reader["IntallmentPlanCode"].ToString();
                        info.intId = Convert.ToInt32(reader["id"].ToString());
                    }
                    conn.Close();
                }
            }
            return(info);
        }
        public List <clsInstallmentPlan> GetInstallmentPlans()
        {
            List <clsInstallmentPlan> lst = new List <clsInstallmentPlan>();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand("TMR_USP_GetInstallmentPlans"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = conn;


                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        var info = new clsInstallmentPlan();

                        info.strInstallmentPlanName = reader["InstallmentPlanName"].ToString();
                        info.bInactive             = Convert.ToBoolean(reader["Inactive"]);
                        info.strIntallmentPlanCode = reader["IntallmentPlanCode"].ToString();
                        info.intId = Convert.ToInt32(reader["id"].ToString());
                    }
                    conn.Close();
                }
            }
            return(lst);
        }
        public bool AddInstallmentPlan(clsInstallmentPlan info, ref int id)
        {
            int st = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_AddInstallmentPlan"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@IntallmentPlanCode", info.strIntallmentPlanCode);
                            cmd.Parameters.AddWithValue("@InstallmentPlanName", info.strInstallmentPlanName);
                            cmd.Parameters.AddWithValue("@Inactive", info.bInactive);
                            cmd.Parameters.AddWithValue("@id", info.intId);

                            SqlParameter parm = new SqlParameter();
                            parm.ParameterName = "@Outid";
                            parm.SqlDbType     = SqlDbType.Int;
                            parm.Direction     = ParameterDirection.Output;
                            //parm.Value = info.id;

                            cmd.Parameters.Add(parm);

                            st = cmd.ExecuteNonQuery();

                            id = (int)parm.Value;
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }