public int Insert_Auth(Account_Info obj) { SetError(0, String.Empty); if (string.IsNullOrEmpty(obj.Account_ID)) { SetError(98, "Invalid Account ID"); return(Error_Number); } if (string.IsNullOrEmpty(obj.Name)) { SetError(98, "Invalid Account Name"); return(Error_Number); } Branches dalBranch = new Branches(); if (dalBranch.GetBranchesByID(obj.Branch_ID) == null) { SetError(70, "Branch Id not find"); return(Error_Number); } Categories dalCat = new Categories(); Categories_Info catInfo = dalCat.GetCategoriesByID(obj.Categories); if (catInfo == null) { SetError(71, "Categories Id not find"); return(Error_Number); } Customer dalCust = new Customer(); Customer_Info custInfo = dalCust.GetCustomerByID(obj.Customer_ID); if (custInfo == null) { SetError(1, "Customer not find"); return(Error_Number); } if (!custInfo.Active) { SetError(3, "Customer has been not active"); return(Error_Number); } Account_Info acInfo = base.GetAccountBy(obj.Branch_ID, obj.Categories, obj.Customer_ID); if (acInfo != null) { SetError(12, "Account opened"); return(Error_Number); } acInfo = base.GetAccountById(obj.Account_ID); if (acInfo != null) { SetError(12, "Account opened"); return(Error_Number); } return(Error_Number); }
public static int Update(Categories_Info obj) { if (obj != null) { return(dal_cat.Update(obj.ID, obj.Name, obj.Account_GL.Account_ID)); } else { throw new Exception(dal_cat.Error_Message); } }
protected int Delete(Categories_Info catInfo) { if (string.IsNullOrEmpty(catInfo.ID)) { throw new Exception("catId is null or empty"); } _dalCat.RemoveOneCategories(catInfo.ID); if (_dalCat.Execute()) { return(_dalCat.LastRecordsEffected); } throw _dalCat.GetException; }
protected int Update(Categories_Info catInfo) { if (catInfo == null) { throw new Exception("catInfo is null or empty"); } _dalCat.EditOneCategories(catInfo); if (_dalCat.Execute()) { return(_dalCat.LastRecordsEffected); } throw _dalCat.GetException; }
/// <summary> /// Sửa thông tin sản phẩm chi tiết /// </summary> /// <param name="objCategoriesInfo">thông tin sản phẩm chi tiết</param> /// <returns></returns> public SqlCommand EditOneCategories(Categories_Info objCategoriesInfo) { SqlCommand command = new SqlCommand(@"UPDATE Categories SET Name = @Name, Account_GL = @Account_GL WHERE ID = @ID"); command.CommandType = CommandType.Text; command.Parameters.Add("@ID", SqlDbType.NVarChar, 25).Value = objCategoriesInfo.ID; command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objCategoriesInfo.Name; command.Parameters.Add("@Account_GL", SqlDbType.NVarChar, 25).Value = objCategoriesInfo.Account_GL.Account_ID; this.AddCommand(command); return(command); }
public ActionResult ShowViewCategory(decimal p_id) { try { Category_BL _Category_BL = new Category_BL(); Categories_Info _Categories_Info = _Category_BL.Category_GetById(p_id); ViewBag.obj = _Categories_Info; return(PartialView("~/Areas/ModuleProduct/Views/Category/P_View_Category.cshtml")); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); return(PartialView("P_View_Category")); } }
/// <summary> /// lấy mã tài khoản GL gắn với mã dịch vụ /// </summary> /// <param name="catid">mã sản phẩm</param> /// <returns></returns> private Categories_Info GenerateObj(DataRow ordCategories) { if (ordCategories == null) { throw new Exception("Data row is empty or null"); } Categories_Info objCategoriesInfo = new Categories_Info(); if (ordCategories["CatID"] != DBNull.Value) { objCategoriesInfo.ID = Convert.ToString(ordCategories["CatID"]); } if (ordCategories["CatName"] != DBNull.Value) { objCategoriesInfo.Name = Convert.ToString(ordCategories["CatName"]); } Account_GL_Info objAccountGlInfo = new Account_GL_Info(); if (ordCategories["Branch_ID"] != DBNull.Value) { objAccountGlInfo.Branch_ID = Convert.ToString(ordCategories["Branch_ID"]); } if (ordCategories["Account_ID"] != DBNull.Value) { objAccountGlInfo.Account_ID = Convert.ToString(ordCategories["Account_ID"]); } if (ordCategories["Name"] != DBNull.Value) { objAccountGlInfo.Name = Convert.ToString(ordCategories["Name"]); } if (ordCategories["CreditDebit"] != DBNull.Value) { objAccountGlInfo.CreditDebit = (AccountType)Enum.Parse(typeof(AccountType), ordCategories["CreditDebit"].ToString()); } if (ordCategories["Ccy"] != DBNull.Value) { objAccountGlInfo.Ccy = Convert.ToString(ordCategories["Ccy"]); } objCategoriesInfo.Account_GL = objAccountGlInfo; return(objCategoriesInfo); }
public int Update(string id, string name, string account_GL) { if (string.IsNullOrEmpty(id)) { SetError(98, "Categories Id is null or empty"); return(Error_Number); } if (string.IsNullOrEmpty(name)) { SetError(98, "Categories name is null or empty"); return(Error_Number); } AccountGL dal_AcGL = new AccountGL(); Account_GL_Info acGLInfo = dal_AcGL.GetAccountGLByID(account_GL); if (acGLInfo == null) { SetError(98, "Account_GL not find"); return(Error_Number); } Categories_Info catInfo = base.GetCategoriesById(id); if (catInfo == null) { SetError(99, "Categories not find"); return(Error_Number); } // Set info catInfo.Name = name; catInfo.Account_GL = acGLInfo; if (base.Update(catInfo) != 0) { SetError(0, string.Empty); } else { SetError(99, _dalCat.GetException.Message); } return(Error_Number); }
/// <summary> /// /// </summary> /// <param name="objCategoriesInfo"></param> /// <returns></returns> public SqlCommand CreateOneCategories(Categories_Info objCategoriesInfo) { SqlCommand command = new SqlCommand(@"INSERT INTO Categories( ID, Name, Account_GL ) VALUES ( @ID, @Name, @Account_GL )"); command.CommandType = CommandType.Text; command.Parameters.Add("@ID", SqlDbType.NVarChar, 25).Value = objCategoriesInfo.ID; command.Parameters.Add("@Name", SqlDbType.NVarChar, 135).Value = objCategoriesInfo.Name; command.Parameters.Add("@Account_GL", SqlDbType.NVarChar, 25).Value = objCategoriesInfo.Account_GL.Account_ID; this.AddCommand(command); return(command); }
public int Delete(string id) { if (string.IsNullOrEmpty(id)) { SetError(98, "Categories Id is null or empty"); return(Error_Number); } Categories_Info catInfo = base.GetCategoriesById(id); if (catInfo == null) { SetError(99, "Categories not find"); return(Error_Number); } if (base.Delete(catInfo) != 0) { SetError(0, string.Empty); } else { SetError(99, _dalCat.GetException.Message); } return(Error_Number); }
/// <summary> /// Mở tài khoản theo Categories và mã khách hàng /// </summary> /// <param name="categories">Mã sản phẩm</param> /// <param name="custId">Mã khách hàng</param> /// <returns>chuỗi ký tự thông tin tài khoản chi tiết được mở theo định dạng /// xml hoặc chuối ký tự lỗi định dạng xml</returns> public xml_response Insert(string categories, string custId) { try { _res = new xml_response(); _res.function_name = this.ToString() + string.Format(".Insert({0},{1})", categories, custId); Customer bcust = new Customer(); Customer_Info custInfo = bcust.GetCustomerByID(custId); if (custInfo == null) { _res.SetError("01", "Customer can not find"); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } else { if (custInfo.Active == false) { _res.SetError("03", "Customers have not been approved"); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } } Categories dalCat = new Categories(); Categories_Info catInfo = dalCat.GetCategoriesByID(categories); if (catInfo == null) { _res.SetError("98", string.Format("Categories Id {0} can not find", categories)); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } Account_Info acInfo = GetAccountBy(_channel.Branch, categories, custId); if (acInfo == null) { // Khởi tạo thông tin mở tài khoản. acInfo = new Account_Info(); acInfo.Name = custInfo.Name; // tên tài khoản. acInfo.Customer_ID = custInfo.ID; // Mã khách hàng. acInfo.Branch_ID = _channel.Branch; acInfo.Categories = categories; acInfo.Ccy = _channel.Currency_Code; acInfo.Account_GL = catInfo.Account_GL.Account_ID; acInfo.CreditDebit = catInfo.Account_GL.CreditDebit; acInfo.Approved = true; acInfo.ApprovedTime = DateTime.Now; acInfo.UserCreate = _channel.UserLogin; acInfo.Account_ID = GenerateNewAccountId(acInfo.Branch_ID, acInfo.Categories); acInfo.Open_Date = DateTime.Now; acInfo.Last_Date = DateTime.Now; // thực hiện mở tài khoản. if (Insert(acInfo) == 0) { _res.Accounts = acInfo.RenderXML(); } else { // Lấy nội dung lỗi _res.SetError("99", dalAc.GetException.Message); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } return(_res); } } else { // tài khoản đã được mở _res.SetError("12", "Account opened"); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } } } catch (Exception ex) { _res.SetError("99", ex.Message); if (logger.IsErrorEnabled) { logger.Error(string.Format("{0}\t{1}", _res.error_code, _res.error_msg)); } } return(_res); }