Пример #1
0
        /// <summary>
        /// Hàm cập nhật thông tin khách hàng
        /// </summary>
        /// <param name="cc">CustomerClass</param>
        /// <returns></returns>
        public int InsertOrUpdateCustomer(CustomerClass cc)
        {
            ConnectionData data = null;
            Hashtable      ht   = null;

            try
            {
                data = new ConnectionData();
                ht   = new Hashtable();
                ht.Add("CustomerCode", cc.CustomerCode);
                ht.Add("CustomerName", cc.CustomerName);
                ht.Add("Address", cc.Address);
                ht.Add("Phone", cc.Phone);
                ht.Add("GroupId", cc.GroupId);
                ht.Add("Note", cc.Note);
                int result = data.ExcNonQuery("sp_Customer_InsertOrUpdate", ht);
                return(result);
            }
            catch
            {
                throw;
            }
            finally
            {
                data.CloseConnect();//Đóng kết nối
                ht = null;
            }
        }
Пример #2
0
 public string DeleteCustomer(CustomerClass cc)
 {
     if (string.IsNullOrEmpty(Context.Session["UserName"].ToString()))
     {
         return(ResultObject.ReturnResult("Phiên làm việc kết thúc, mời bạn đăng nhập lại", false));
     }
     else
     {
         string mess = "Xóa thông tin khách hàng thất bại. Mời thao tác lại!";
         try
         {
             if (cc.CustomerDelete(cc) > 0)
             {
                 mess = "Ok";
             }
         }
         catch (SqlException ex)
         {
             return(ResultObject.ReturnResult("DeleteCustomer-SqlException:" + ex.Message, false));
         }
         catch (ArgumentException ex)
         {
             return(ResultObject.ReturnResult("DeleteCustomer-ArgumentException:" + ex.Message, false));
         }
         return(ResultObject.ReturnResult(mess, true));
     }
 }
Пример #3
0
        public string GetAllCustomer()
        {
            CustomerClass cc = new CustomerClass();
            DataTable     dt = new DataTable();

            try
            {
                using (dt = cc.GetAllCustomer())
                {
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        StringBuilder htmlText = new StringBuilder();
                        htmlText.AppendLine("<table width='100%' class='table table-striped table-bordered table-hover' id='dataTables-example'>");
                        htmlText.AppendLine("<thead><tr>");
                        htmlText.AppendLine(
                            "<th>Mã khách hàng</th>" +
                            "<th>Tên khách hàng</th>" +
                            "<th>Số điện thoại</th>" +
                            "<th>Địa chỉ</th>" +
                            "<th>Nhóm địa chỉ</th>" +
                            "<th>Công nợ</th>" +
                            "<th>Ghi chú</th>" +
                            "<th>Chọn</th>" +
                            "<th>Chức năng</th>");
                        htmlText.AppendLine("</tr></thead>");
                        htmlText.AppendLine("<tbody>");
                        foreach (DataRow dr in dt.Rows)
                        {
                            string btnSua = "<a data-toggle='modal' data-target='#InsertOrUpdate' href=\"javascript:void(0)\" style=\"text-decoration: none;\"><img src=\"../Images/edit.png\" id=\"imgEdit\" class=\"imgbtn\" title=\"Sửa thông tin\"alt=\"InsertOrUpdate\" onclick=\"InsertOrUpdate('" + dr["CustomerCode"] + "','" + dr["CustomerName"] + "','" + dr["Phone"] + "','" + dr["Address"] + "','" + dr["GroupName"] + "','" + dr["Note"] + "')\" /></a>";
                            string btnXoa = "<a data-toggle='modal' data-target='#Delete' href=\"javascript:void(0)\" style=\"text-decoration: none;\"><img src=\"../Images/delete.png\"  id=\"imgXoa\"   class=\"imgbtn\" title=\"Xóa khách hàng\"     alt=\"Delete\" onclick=\"Delete('" + dr["CustomerCode"] + "','" + dr["CustomerName"] + "')\" /></a>";
                            htmlText.AppendLine("<td>" + dr["CustomerCode"] + "</td>");
                            htmlText.AppendLine("<td>" + dr["CustomerName"] + "</td>");
                            htmlText.AppendLine("<td>" + dr["Phone"] + "</td>");
                            htmlText.AppendLine("<td>" + dr["Address"] + "</td>");
                            htmlText.AppendLine("<td>" + dr["GroupName"] + "</td>");
                            htmlText.AppendLine("<td>10.000.000 Đ</td>");
                            htmlText.AppendLine("<td>" + dr["Note"] + "</td>");
                            htmlText.AppendLine("<td style='text-align:center'><input id='tick-choose-customer' type='checkbox' value='" + dr["CustomerCode"] + "'/></td>");
                            htmlText.AppendLine("<td style='text-align:center'>" + btnSua + btnXoa + "</td>");
                            htmlText.AppendLine("</tr>");
                        }
                        htmlText.AppendLine("</tbody>");
                        htmlText.AppendLine("</table>");
                        return(ResultObject.ReturnResult(htmlText.ToString(), true));
                    }
                    return(ResultObject.ReturnResult("Không có bản ghi nào phù hợp với bộ lọc, hãy kiểm tra lại.", false));
                }
            }
            catch (SqlException ex)
            {
                return(ResultObject.ReturnResult("GetAllCustomer-SqlException:" + ex.Message, false));
            }
            catch (ArgumentException ex)
            {
                return(ResultObject.ReturnResult("GetAllCustomer-ArgumentException:" + ex.Message, false));
            }
        }
Пример #4
0
 public string GetCustomerCodeInsert()
 {
     try
     {
         CustomerClass cc = new CustomerClass();
         return(ResultObject.ReturnResult(cc.GetCustomerCodeInsert(), true));
     }
     catch (SqlException ex)
     {
         return(ResultObject.ReturnResult("GetCustomerCodeInsert-SqlException:" + ex.Message, false));
     }
     catch (ArgumentException ex)
     {
         return(ResultObject.ReturnResult("GetCustomerCodeInsert-ArgumentException:" + ex.Message, false));
     }
 }
Пример #5
0
        /// <summary>
        /// Hàm xóa thông tin khách hàng
        /// </summary>
        /// <param name="cc"></param>
        /// <returns></returns>
        public int CustomerDelete(CustomerClass cc)
        {
            ConnectionData data = null;
            Hashtable      ht   = null;

            try
            {
                data = new ConnectionData();
                ht   = new Hashtable();
                ht.Add("CustomerCode", cc.CustomerCode);
                int result = data.ExcNonQuery("sp_Customer_Delete", ht);
                return(result);
            }
            catch
            {
                throw;
            }
            finally
            {
                data.CloseConnect();//Đóng kết nối
                ht = null;
            }
        }