public clsReceiptEntry GetReceiptEntry(int id)
        {
            clsReceiptEntry entry = new clsReceiptEntry();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                using (SqlCommand cmd = new SqlCommand("TMR_USP_GetReceiptEntry"))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = conn;
                    conn.Open();

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

                    while (reader.Read())
                    {
                        entry.intId            = Convert.ToInt32(reader["id"]);
                        entry.RegistrationNo   = reader["RegistrationNo"].ToString();
                        entry.ClientName       = reader["ClientName"].ToString();
                        entry.ClientID         = reader["ClientID"].ToString();
                        entry.ReceiptAmount    = Convert.ToDecimal(reader["ReceiptAmount"]);
                        entry.AppliedAmount    = Convert.ToDecimal(reader["AppliedAmount"]);
                        entry.CurrentAmount    = Convert.ToDecimal(reader["CurrentAmount"]);
                        entry.ReceiptMode      = reader["ReceiptMode"].ToString();
                        entry.InstrumentNumber = reader["InstrumentNumber"].ToString();
                        entry.InstrumentDate   = Convert.ToDateTime(reader["InstrumentDate"]);
                        entry.DraweeBank       = reader["DraweeBank"].ToString();
                        entry.DraweeBranch     = reader["DraweeBranch"].ToString();
                        entry.DepositBank      = reader["DepositBank"].ToString();
                        entry.DepositAccount   = reader["DepositAccount"].ToString();
                        entry.DepositBy        = reader["DepositBy"].ToString();
                        entry.DepositDate      = Convert.ToDateTime(reader["DepositDate"]);
                        entry.ClearanceDate    = Convert.ToDateTime(reader["ClearanceDate"]);
                        entry.Remarks          = reader["Remarks"].ToString();
                        entry.ReceiptDate      = Convert.ToDateTime(reader["ReceiptDate"]);
                        entry.ReceiptNumber    = reader["ReceiptNumber"].ToString();
                        entry.OnAccountOf      = reader["OnAccount"].ToString();
                        entry.ClearStatus      = reader["ClearedStatus"].ToString();

                        entry.Cleared  = Convert.ToBoolean(reader["Cleared"]);
                        entry.Project  = reader["Project"].ToString();
                        entry.SentToGP = Convert.ToBoolean(reader["SentToGp"]);
                    }
                    conn.Close();
                }
            }
            return(entry);
        }
        public bool CreateCashReceipt(clsReceiptEntry info, string BatchNumber)
        {
            int st = 0;

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

                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_CreateCashReceipt"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@Batch", BatchNumber);
                            cmd.Parameters.AddWithValue("@DOCNUMBR", info.ReceiptNumber);

                            cmd.Parameters.AddWithValue("@CustNMBR", info.RegistrationNo);
                            cmd.Parameters.AddWithValue("@DOCDATE", info.ReceiptDate.Date);

                            cmd.Parameters.AddWithValue("@CSHRCTYP", 0);
                            cmd.Parameters.AddWithValue("@CHEKNMBR", info.InstrumentNumber);
                            cmd.Parameters.AddWithValue("@CHEKBKID", info.DepositBank);//info.FatherOrHusbandType);
                            cmd.Parameters.AddWithValue("@TRXDESCRN", info.Remarks);
                            cmd.Parameters.AddWithValue("@LSTEDTDT", DateTime.Now.Date);
                            cmd.Parameters.AddWithValue("@ORTRXAMT", info.ReceiptAmount);
                            cmd.Parameters.AddWithValue("@GLPOSTDT", DateTime.Now.Date);

                            //@CNIC varchar(50), @Project varchar(50), @PHONEOFF varchar(50), @PHONERES varchar(50), @MOBILE varchar(50)

                            st = cmd.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public List <clsReceiptEntry> GetUnsentReceiptsList()
        {
            List <clsReceiptEntry> lst = new List <clsReceiptEntry>();

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

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

                    //cmd.Parameters.AddWithValue("@RegistrationNo", clsdoc.strRegistrationNo);
                    //cmd.Parameters.AddWithValue("@ProjectID", clsdoc.strProjectID);
                    //cmd.Parameters.AddWithValue("@ClientID", clsdoc.strClientID);
                    //cmd.Parameters.AddWithValue("@StartDate", clsdoc.dateStartDate);
                    //cmd.Parameters.AddWithValue("@EndDate", clsdoc.dateEndDate);
                    //cmd.Parameters.AddWithValue("@ReceiptNumber", clsdoc.strDocNumber);


                    SqlDataReader reader = cmd.ExecuteReader();

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

                        info.RegistrationNo = reader["RegistrationNo"].ToString();
                        info.ClientID       = reader["ClientID"].ToString();
                        info.ClientName     = reader["ClientName"].ToString();
                        info.ReceiptNumber  = reader["ReceiptNumber"].ToString();
                        info.ReceiptDate    = Convert.ToDateTime(reader["ReceiptDate"]);
                        info.ReceiptAmount  = Convert.ToDecimal(reader["ReceiptAmount"]);
                        info.Remarks        = reader["Remarks"].ToString();
                        info.ClearanceDate  = Convert.ToDateTime(reader["ClearanceDate"]);
                        info.DepositBank    = reader["DepositBank"].ToString();
                        info.intId          = Convert.ToInt32(reader["id"]);

                        lst.Add(info);
                    }
                    conn.Close();
                }
            }
            return(lst);
        }
        public bool AddReceiptEntry(clsReceiptEntry entry)
        {
            int st = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();
                    {
                        using (SqlCommand cmd = new SqlCommand("TMR_USP_AddReceiptEntry"))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Connection  = conn;
                            cmd.Parameters.AddWithValue("@RegistrationNo", entry.RegistrationNo);
                            cmd.Parameters.AddWithValue("@ClientID", entry.ClientID);
                            cmd.Parameters.AddWithValue("@ClientName", entry.ClientName);
                            cmd.Parameters.AddWithValue("@Membership_id", entry.Membership_id);
                            cmd.Parameters.AddWithValue("@ReceiptNumber", entry.ReceiptNumber);
                            cmd.Parameters.AddWithValue("@ReceiptDate", entry.ReceiptDate);
                            cmd.Parameters.AddWithValue("@ReceiptAmount", entry.ReceiptAmount);

                            cmd.Parameters.AddWithValue("@AppliedAmount", entry.AppliedAmount);
                            cmd.Parameters.AddWithValue("@CurrentAmount", entry.CurrentAmount);
                            cmd.Parameters.AddWithValue("@ReceiptMode", entry.ReceiptMode);
                            cmd.Parameters.AddWithValue("@InstrumentNumber", entry.InstrumentNumber);
                            cmd.Parameters.AddWithValue("@InstrumentDate", entry.InstrumentDate);
                            cmd.Parameters.AddWithValue("@DraweeBank", entry.DraweeBank);
                            cmd.Parameters.AddWithValue("@DraweeBranch", entry.DraweeBranch);

                            cmd.Parameters.AddWithValue("@DepositBank", entry.DepositBank);
                            cmd.Parameters.AddWithValue("@DepositAccount", entry.DepositAccount);
                            cmd.Parameters.AddWithValue("@DepositBy", entry.DepositBy);
                            cmd.Parameters.AddWithValue("@DepositDate", entry.DepositDate);
                            cmd.Parameters.AddWithValue("@ClearanceDate", entry.ClearanceDate);
                            cmd.Parameters.AddWithValue("@Remarks", entry.Remarks);

                            cmd.Parameters.AddWithValue("@Cleared", entry.Cleared);
                            cmd.Parameters.AddWithValue("@sentToGP", entry.SentToGP);
                            cmd.Parameters.AddWithValue("@Project", entry.Project);

                            cmd.Parameters.AddWithValue("@OnAccount", entry.OnAccountOf);
                            cmd.Parameters.AddWithValue("@ClearedStatus", entry.ClearStatus);

                            cmd.Parameters.AddWithValue("@id", entry.intId);



                            st = cmd.ExecuteNonQuery();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex) { }
            if (st > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }