示例#1
0
        public ENResult update(uspGEProductSearch_Result data, IList <ENProductProperty> listProperty, IList <ENProductProperty> listPropertyDelete)
        {
            try
            {
                using (erpStoreEntities db = new erpStoreEntities())
                {
                    db.uspGEProductUpdate(data.idProduct, data.idCategory, data.idBrand, data.codeUnit, data.name, data.divisible,
                                          data.divisibleCodeUnit, data.divisibleNumberParts, data.perishable, data.traceable, data.barcodeType,
                                          PUser, PReturnCode, PReturnMessage);
                    if (Convert.ToInt32(PReturnCode.Value) == 0)
                    {
                        if (listProperty != null)
                        {
                            for (int i = 0; i < listProperty.Count; i++)
                            {
                                ENProductProperty temp = listProperty[i];
                                if (temp.idProperty == 0)
                                {
                                    db.uspGEProductPropertyInsert(data.idProduct, temp.name, temp.abbreviation, temp.required, PUser, PReturnCode, PReturnMessage);
                                }
                                else
                                {
                                    db.uspGEProductPropertyUpdate(temp.idProperty, data.idProduct, temp.name, temp.abbreviation, temp.required, PUser, PReturnCode, PReturnMessage);
                                }
                                if (Convert.ToInt32(PReturnCode.Value) != 0)
                                {
                                    break;
                                }
                            }
                        }
                        if (listPropertyDelete != null)
                        {
                            for (int i = 0; i < listPropertyDelete.Count; i++)
                            {
                                ENProductProperty temp = listPropertyDelete[i];
                                db.uspGEProductPropertyDelete(data.idProduct, temp.idProperty, PUser, PReturnCode, PReturnMessage);

                                if (Convert.ToInt32(PReturnCode.Value) != 0)
                                {
                                    break;
                                }
                            }
                        }
                        return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
                    }
                    else
                    {
                        return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
                    }
                }
            }
            catch (Exception ex)
            {
                return(PUnexpectedError(ex));
            }
        }
示例#2
0
 public ENResult delete(uspGEProductSearch_Result data)
 {
     try
     {
         using (erpStoreEntities db = new erpStoreEntities())
         {
             db.uspGEProductDelete(data.idProduct, PUser, PReturnCode, PReturnMessage);
             return(new ENResult(Convert.ToInt32(PReturnCode.Value), Convert.ToString(PReturnMessage.Value)));
         }
     }
     catch (Exception ex)
     {
         return(PUnexpectedError(ex));
     }
 }