Example #1
0
        public bool AddMBranch(MBranch mbranch)
        {
            SqlCommand cmd;

            cmd             = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "AddMBranch";

            cmd.Parameters.AddWithValue("@BranchNo", mbranch.BranchNo);

            cmd.Parameters.AddWithValue("@BranchName", mbranch.BranchName);

            cmd.Parameters.AddWithValue("@IsActive", mbranch.IsActive);

            cmd.Parameters.AddWithValue("@UserID", mbranch.UserID);

            cmd.Parameters.AddWithValue("@UserDate", mbranch.UserDate);

            cmd.Parameters.AddWithValue("@CompanyNo", mbranch.CompanyNo);
            if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true)
            {
                return(true);
            }
            else
            {
                mbranch.msg = ObjTrans.ErrorMessage;
                return(false);
            }
        }
Example #2
0
        public MBranch ModifyMBranchByID(long ID)
        {
            SqlConnection Con = new SqlConnection(CommonFunctions.ConStr);
            string        sql;
            SqlCommand    cmd;

            sql            = "Select * from MBranch where BranchNo =" + ID;
            cmd            = new SqlCommand(sql, Con);
            cmd.Connection = Con;
            Con.Open();
            cmd.CommandType = CommandType.Text;
            SqlDataReader dr;

            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (dr.HasRows)
            {
                MBranch MM = new MBranch();
                while (dr.Read())
                {
                    MM.BranchNo = Convert.ToInt32(dr["BranchNo"]);
                    if (!Convert.IsDBNull(dr["BranchName"]))
                    {
                        MM.BranchName = Convert.ToString(dr["BranchName"]);
                    }
                    if (!Convert.IsDBNull(dr["IsActive"]))
                    {
                        MM.IsActive = Convert.ToBoolean(dr["IsActive"]);
                    }
                    if (!Convert.IsDBNull(dr["UserID"]))
                    {
                        MM.UserID = Convert.ToInt64(dr["UserID"]);
                    }
                    if (!Convert.IsDBNull(dr["UserDate"]))
                    {
                        MM.UserDate = Convert.ToDateTime(dr["UserDate"]);
                    }
                    if (!Convert.IsDBNull(dr["ModifiedBy"]))
                    {
                        MM.ModifiedBy = Convert.ToString(dr["ModifiedBy"]);
                    }
                    if (!Convert.IsDBNull(dr["CompanyNo"]))
                    {
                        MM.CompanyNo = Convert.ToInt64(dr["CompanyNo"]);
                    }
                }
                dr.Close();
                return(MM);
            }
            else
            {
                dr.Close();
            }
            return(new MBranch());
        }
Example #3
0
        public bool DeleteMBranch(MBranch mbranch)
        {
            SqlCommand cmd;

            cmd             = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "DeleteMBranch";

            cmd.Parameters.AddWithValue("@BranchNo", mbranch.BranchNo);
            if (ObjTrans.ExecuteNonQuery(cmd, CommonFunctions.ConStr) == true)
            {
                return(true);
            }
            else
            {
                mbranch.msg = ObjTrans.ErrorMessage;
                return(false);
            }
        }