private int ImportColor(string name, string hexaColor) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Attribute attr = new Class_Attribute(); TBValue size = db.TBValues.Where(x => !x.Deflag && x.IDAttribute == attr.IDColor && x.Name.ToLower() == name.ToLower()).FirstOrDefault(); if (size == null) { TBValue _newVal = new TBValue(); _newVal.IDAttribute = attr.IDColor; _newVal.Name = name; _newVal.RGBColor = hexaColor; db.TBValues.InsertOnSubmit(_newVal); db.SubmitChanges(); return(_newVal.IDValue); } else { return(size.IDValue); } } catch (Exception) { return(0); } }
public ReturnData AJAX_Delete(int idValue) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { TBValue _deleteData = GetDetail(db, idValue); if (_deleteData == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } string _nameBefore = _deleteData.Name; _deleteData.Deflag = true; _deleteData.DateLastUpdate = DateTime.Now; db.SubmitChanges(); return(ReturnData.MessageSuccess(_nameBefore + " has been successfully deleted.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
private int ImportSize(string Size) { try { DataClassesDataContext db = new DataClassesDataContext(); Class_Attribute attr = new Class_Attribute(); TBValue size = db.TBValues.Where(x => !x.Deflag && x.IDAttribute == attr.IDSize && x.Name.ToLower() == Size.ToLower()).FirstOrDefault(); if (size == null) { TBValue _newVal = new TBValue(); _newVal.IDAttribute = attr.IDSize; _newVal.Name = Size; _newVal.DateInsert = DateTime.Now; _newVal.DateLastUpdate = DateTime.Now; db.TBValues.InsertOnSubmit(_newVal); db.SubmitChanges(); return(_newVal.IDValue); } else { return(size.IDValue); } } catch (Exception) { return(0); } }
public ReturnData AJAX_Insert(int idAttribute, string name, string rgbColor) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { if (new Class_Attribute().Dynamic_GetDetail(db, idAttribute) == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } if (!ValidationName_Insert(db, name, idAttribute)) { return(ReturnData.MessageFailed(name + " already exists.", null)); } TBValue _newData = new TBValue { IDAttribute = idAttribute, Name = name, RGBColor = rgbColor, Deflag = false, DateInsert = DateTime.Now, DateLastUpdate = DateTime.Now }; db.TBValues.InsertOnSubmit(_newData); db.SubmitChanges(); if (_newData != null) { return(ReturnData.MessageSuccess(name + " has been successfully inserted.", null)); } return(ReturnData.MessageFailed(name + " failed to insert.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
public ReturnData AJAX_Update(int idValue, string name, string rgbColor) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { TBValue _updateData = GetDetail(db, idValue); if (_updateData == null) { return(ReturnData.MessageFailed("The requested resource does not exist.", null)); } if (!ValidationName_Update(db, idValue, name, _updateData.IDAttribute)) { return(ReturnData.MessageFailed(name + " already exists.", null)); } string _nameBefore = _updateData.Name; _updateData.Name = name; _updateData.RGBColor = rgbColor; _updateData.DateLastUpdate = DateTime.Now; db.SubmitChanges(); if (_updateData != null) { return(ReturnData.MessageSuccess(_nameBefore + " has been successfully updated.", null)); } return(ReturnData.MessageSuccess(_nameBefore + " failed to update.", null)); } } catch (Exception ex) { Class_Log_Error log = new Class_Log_Error(); log.Insert(ex.Message, ex.StackTrace); return(ReturnData.MessageFailed(ex.Message, null)); } }
private int ImportCombination(int idProduct, string referenceCode, decimal basePrice, decimal priceBeforeImpact, decimal impactPrice, decimal PriceAfterImpact, decimal price, decimal impactWeight, decimal weight, int Quantity, int idColor, int idSize) { try { DataClassesDataContext db = new DataClassesDataContext(); int firstQty = 0; Class_Employee emp = new Class_Employee(); var employee = emp.GetData_By_Token(HttpContext.Current.Request.Cookies[System.Configuration.ConfigurationManager.AppSettings["cookieAdmin"].ToString()].Value); if (db.TBProduct_Combinations.Where(x => !x.Deflag && x.ReferenceCode == referenceCode).FirstOrDefault() != null) { TBProduct_Combination data = db.TBProduct_Combinations.Where(x => !x.Deflag && x.ReferenceCode == referenceCode).FirstOrDefault(); firstQty = data.Quantity; data.Quantity = Quantity; db.SubmitChanges(); return(data.IDProduct_Combination); } TBProduct_Combination _newData = new TBProduct_Combination(); TBValue color = db.TBValues.Where(x => !x.Deflag && x.IDValue == idColor).FirstOrDefault(); TBValue size = db.TBValues.Where(x => !x.Deflag && x.IDValue == idSize).FirstOrDefault(); _newData.IDProduct = idProduct; _newData.ReferenceCode = referenceCode; _newData.Name = color.TBAttribute.Name + " : " + color.Name + ", " + size.TBAttribute.Name + " : " + size.Name; _newData.DateInsert = DateTime.Now; _newData.DateLastUpdate = DateTime.Now; _newData.BasePrice = basePrice; _newData.PriceBeforeImpact = priceBeforeImpact; _newData.PriceAfterImpact = PriceAfterImpact; _newData.Price = price; _newData.WeightBeforeImpact = weight; _newData.Weight = weight; _newData.Quantity = Quantity; _newData.DateLastUpdate = DateTime.Now; _newData.DateInsert = DateTime.Now; db.TBProduct_Combinations.InsertOnSubmit(_newData); db.SubmitChanges(); //INSERT DETAIL COMBINATAION COLOR TBProduct_Combination_Detail _detail = new TBProduct_Combination_Detail(); _detail.IDProduct_Combination = _newData.IDProduct_Combination; _detail.IDValue = color.IDValue; _detail.NameAttribute = color.TBAttribute.Name; _detail.NameValue = color.Name; _detail.DateInsert = DateTime.Now; db.TBProduct_Combination_Details.InsertOnSubmit(_detail); //INSERT DETAIL COMBINATAION Size TBProduct_Combination_Detail _detailSize = new TBProduct_Combination_Detail(); _detailSize.IDProduct_Combination = _newData.IDProduct_Combination; _detailSize.IDValue = size.IDValue; _detailSize.NameAttribute = size.TBAttribute.Name; _detailSize.NameValue = size.Name; _detailSize.DateInsert = DateTime.Now; db.TBProduct_Combination_Details.InsertOnSubmit(_detailSize); db.SubmitChanges(); //INSERT LOG Class_Log_Stock log = new Class_Log_Stock(); log.Insert(employee.IDEmployee, _detail.TBProduct_Combination.IDProduct_Combination, _detail.TBProduct_Combination.Name, firstQty, Quantity, Quantity, "initial", "Import master product" + " by " + employee.Name + "( " + employee.Email + " )"); return(_newData.IDProduct_Combination); } catch (Exception) { return(0); } }