Esempio n. 1
0
 public Raw_Material_Attachment GetRawMaterialAttachment(Nullable <System.Guid> pAttID)
 {
     using (var db = new AgnosDBContext())
     {
         return(db.Raw_Material_Attachment.Where(w => w.Attachment_ID == pAttID && w.Record_Status != Record_Status.Delete).FirstOrDefault());
     }
 }
Esempio n. 2
0
 public int DeleteAttachment(Nullable <System.Guid> pAttachmentID)
 {
     try
     {
         using (var db = new AgnosDBContext())
         {
             var attach = db.Raw_Material_Attachment.Where(w => w.Attachment_ID == pAttachmentID).FirstOrDefault();
             if (attach == null)
             {
                 return(-500);
             }
             else
             {
                 attach.Record_Status   = Record_Status.Delete;
                 attach.Update_On       = currentdate;
                 attach.Update_By       = userlogin.Email_Address;
                 db.Entry(attach).State = EntityState.Modified;
                 //db.Raw_Material_Attachment.Remove(attach);
                 db.SaveChanges();
                 return(1);
             }
         }
     }
     catch
     {
         //Log
         return(-500);
     }
 }
Esempio n. 3
0
        public ServiceResult GetRole(RoleCriteria cri = null)
        {
            var result = new ServiceResult();

            try
            {
                using (var db = new AgnosDBContext())
                {
                    var rows = db.Roles
                               .Where(w => 1 == 1);

                    if (cri != null)
                    {
                        if (cri.Role_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Role_ID == cri.Role_ID);
                        }
                    }
                    result.Object = rows.OrderByDescending(o => o.Role_Name).ToList();
                    result.Code   = ReturnCode.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                result.Code      = ReturnCode.ERROR_DB;
                result.Exception = ex;
            }
            return(result);
        }
Esempio n. 4
0
        public List <ComboRow> LstTemplateByProductTemplate(bool hasBlank = false, string pProductCode = null)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                clist.AddRange(db.Product_Template
                               .Include(i => i.Template_Logsheet)
                               .Where(w => w.Product_Code.Contains(pProductCode) && w.Record_Status != Record_Status.Delete)
                               .OrderBy(o => o.Template_Logsheet.Template_Name)
                               .Select(s => new ComboRow
                {
                    Value = SqlFunctions.StringConvert((double)s.Template_ID).Trim(),
                    Text  = s.Template_Logsheet.Template_Code.Trim() + "  -  " + s.Template_Logsheet.Template_Name.Trim()
                }));

                return(clist);
            }
        }
Esempio n. 5
0
        public ServiceResult UpdateGlobalLookupData(Global_Lookup_Data pData)
        {
            try
            {
                using (var db = new AgnosDBContext())
                {
                    var current = db.Global_Lookup_Data.Where(w => w.Lookup_Data_ID == pData.Lookup_Data_ID).FirstOrDefault();
                    if (current != null)
                    {
                        db.Entry(current).CurrentValues.SetValues(pData);
                        db.SaveChanges();
                    }

                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_UPDATE),
                        Field = Resource.Global_Lookup
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_UPDATE,
                    Msg = Error.GetMessage(ReturnCode.ERROR_UPDATE),
                    Field = Resource.Global_Lookup,
                    Exception = ex
                });
            }
        }
Esempio n. 6
0
 public List <ComboRow> LstFillingStationType(bool includeAll = false)
 {
     using (var db = new AgnosDBContext())
     {
         if (!includeAll)
         {
             return(db.CMS_Filling_Station
                    .Where(w => w.Station_Code != null && w.Record_Status != Record_Status.Delete)
                    .OrderBy(o => SqlFunctions.IsNumeric(o.Station_Code))
                    .Select(s => new ComboRow
             {
                 Value = SqlFunctions.StringConvert((double)s.Filling_Station_ID).Trim(),
                 Text = s.Station_Code
             }).ToList());
         }
         else
         {
             return(db.CMS_Filling_Station
                    .Where(w => w.Station_Code != null)
                    .OrderBy(o => SqlFunctions.IsNumeric(o.Station_Code))
                    .Select(s => new ComboRow
             {
                 Value = SqlFunctions.StringConvert((double)s.Filling_Station_ID).Trim(),
                 Text = s.Station_Code
             }).ToList());
         }
     }
 }
Esempio n. 7
0
 public List <ComboRow> LstDispose(bool hasBlank = false)
 {
     using (var db = new AgnosDBContext())
     {
         var clist = new List <ComboRow>();
         if (hasBlank)
         {
             clist.Add(new ComboRow {
                 Value = "", Text = "-"
             });
         }
         clist.Add(new ComboRow()
         {
             Value = "N/A", Text = "N/A", Desc = "N/A"
         });
         clist.Add(new ComboRow()
         {
             Value = "Internally", Text = "Dispose Internally", Desc = "Dispose Internally"
         });
         clist.Add(new ComboRow()
         {
             Value = "Externally", Text = "Dispose Externally", Desc = "Dispose Dispose"
         });
         return(clist);
     }
 }
Esempio n. 8
0
        public List <ComboRow> LstLookupData(string pDefCode, bool hasBlank = false)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                clist.AddRange(db.Global_Lookup_Data
                               .Where(w => w.Global_Lookup_Def.Def_Code == pDefCode)
                               .OrderBy(o => o.Name)
                               .Select(s => new ComboRow
                {
                    Value = SqlFunctions.StringConvert((double)s.Lookup_Data_ID).Trim(),
                    Text  = s.Name,
                }));

                return(clist);
            }
        }
Esempio n. 9
0
        public List <ComboRow> LstLotNumber(string pProductCode = null, int?pTmpID = null, bool hasBlank = false)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                var lots = db.Lot_Number.Where(w => 1 == 1 && w.Record_Status != Record_Status.Delete);

                if (!string.IsNullOrEmpty(pProductCode))
                {
                    lots = lots.Where(w => w.Product_Code == pProductCode);
                }

                if (pTmpID.HasValue)
                {
                    lots = lots.Where(w => w.Template_ID == pTmpID);
                }

                clist.AddRange(lots
                               .Select(s => new ComboRow
                {
                    Value = SqlFunctions.StringConvert((double)s.Lot_Number_ID).Trim(),
                    Text  = s.Lot_No
                }));

                return(clist);
            }
        }
Esempio n. 10
0
 public Product_Mapping GetProductMapping(string pCode)
 {
     using (var db = new AgnosDBContext())
     {
         return(db.Product_Mapping.Where(w => w.Product_Code == pCode).FirstOrDefault());
     }
 }
Esempio n. 11
0
 public List <ComboRow> LstExchquerProduct(bool hasBlank = false)
 {
     using (var db = new AgnosDBContext())
     {
         var clist = new List <ComboRow>();
         if (hasBlank)
         {
             clist.Add(new ComboRow {
                 Value = "", Text = "-"
             });
         }
         clist.Add(new ComboRow()
         {
             Value = "P0001", Text = "P0001", Desc = "P0001 Name"
         });
         clist.Add(new ComboRow()
         {
             Value = "P0002", Text = "P0002", Desc = "P0002 Name"
         });
         clist.Add(new ComboRow()
         {
             Value = "P0003", Text = "P0003", Desc = "P0003 Name"
         });
         return(clist);
     }
 }
Esempio n. 12
0
        public ServiceResult UpdatePageRole(Page_Role pPR)
        {
            try
            {
                using (var db = new AgnosDBContext())
                {
                    var current = db.Page_Role.Where(w => w.Page_Role_ID == pPR.Page_Role_ID).FirstOrDefault();
                    if (current != null)
                    {
                        db.Entry(current).CurrentValues.SetValues(pPR);
                        db.SaveChanges();
                    }

                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_UPDATE),
                        Field = Resource.Page_Role
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_UPDATE,
                    Msg = Error.GetMessage(ReturnCode.ERROR_UPDATE),
                    Field = Resource.Page_Role,
                    Exception = ex
                });
            }
        }
Esempio n. 13
0
        public ServiceResult InsertMaterialWithdraw(Material_Withdraw pWith)
        {
            try
            {
                using (var db = new AgnosDBContext())
                {
                    pWith.Create_On = currentdate;
                    pWith.Create_By = userlogin.Email_Address;
                    pWith.Update_On = currentdate;
                    pWith.Update_By = userlogin.Email_Address;
                    pWith.PLC       = userlogin.Profile_ID;

                    db.Material_Withdraw.Add(pWith);
                    SaveProductMaping(db, pWith.Product_Code, pWith.Product_Name);
                    db.SaveChanges();
                    db.Entry(pWith).GetDatabaseValues();
                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                        Field = Resource.Material_Withdraw
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_INSERT,
                    Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
                    Field = Resource.Material_Withdraw,
                    Exception = ex
                });
            }
        }
Esempio n. 14
0
        public ServiceResult UpdateMaterialWithdraw(Material_Withdraw pWith)
        {
            try
            {
                using (var db = new AgnosDBContext())
                {
                    var current = db.Material_Withdraw.Where(w => w.Withdraw_ID == pWith.Withdraw_ID).FirstOrDefault();
                    if (current != null)
                    {
                        pWith.Update_On = currentdate;
                        pWith.Update_By = userlogin.Email_Address;
                        SaveProductMaping(db, pWith.Product_Code, pWith.Product_Name);
                        db.Entry(current).CurrentValues.SetValues(pWith);
                        db.SaveChanges();
                    }

                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_UPDATE),
                        Field = Resource.Material_Withdraw
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_UPDATE,
                    Msg = Error.GetMessage(ReturnCode.ERROR_UPDATE),
                    Field = Resource.Material_Withdraw,
                    Exception = ex
                });
            }
        }
Esempio n. 15
0
        public ServiceResult SaveMaterialRejectForm(Material_Reject_Form pForm)
        {
            try
            {
                using (var db = new AgnosDBContext())
                {
                    var form = db.Material_Reject_Form.Where(w => w.Material_Reject_ID == pForm.Material_Reject_ID).FirstOrDefault();
                    if (form != null)
                    {
                        db.Material_Reject_Form.Remove(form);
                    }

                    db.Material_Reject_Form.Add(pForm);
                    db.SaveChanges();
                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                        Field = Resource.Material_Reject
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ServiceResult()
                {
                    Code = ReturnCode.ERROR_INSERT,
                    Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
                    Field = Resource.Attachment_File,
                    Exception = ex
                });
            }
        }
Esempio n. 16
0
 public ServiceResult InsertMaterialRejectForm(Material_Reject_Form pForm)
 {
     try
     {
         using (var db = new AgnosDBContext())
         {
             db.Material_Reject_Form.Add(pForm);
             db.SaveChanges();
             db.Entry(pForm).GetDatabaseValues();
             return(new ServiceResult()
             {
                 Code = ReturnCode.SUCCESS,
                 Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                 Field = Resource.Material_Reject
             });
         }
     }
     catch (Exception ex)
     {
         return(new ServiceResult()
         {
             Code = ReturnCode.ERROR_INSERT,
             Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
             Field = Resource.Material_Reject,
             Exception = ex
         });
     }
 }
Esempio n. 17
0
 public Material_Reject_Form GetMaterialRejectForm(int?pRfID)
 {
     using (var db = new AgnosDBContext())
     {
         return(db.Material_Reject_Form.Where(w => w.Material_Reject_ID == pRfID).FirstOrDefault());
     }
 }
Esempio n. 18
0
 public ServiceResult InsertRawMaterial(Raw_Material pRaw)
 {
     try
     {
         using (var db = new AgnosDBContext())
         {
             SaveProductMaping(db, pRaw.Product_Code, pRaw.Product_Name);
             pRaw.Create_By = userlogin.Email_Address;
             pRaw.Create_On = currentdate;
             pRaw.Update_By = userlogin.Email_Address;
             pRaw.Update_On = currentdate;
             pRaw.Record_By = userlogin.Profile_ID;
             db.Raw_Material.Add(pRaw);
             db.SaveChanges();
             db.Entry(pRaw).GetDatabaseValues();
             return(new ServiceResult()
             {
                 Code = ReturnCode.SUCCESS,
                 Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                 Field = Resource.Income_Raw_Material
             });
         }
     }
     catch (Exception ex)
     {
         return(new ServiceResult()
         {
             Code = ReturnCode.ERROR_INSERT,
             Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
             Field = Resource.Income_Raw_Material,
             Exception = ex
         });
     }
 }
Esempio n. 19
0
 public Raw_Material_Form GetRawMaterialForm(int?pRawID, string pSelStatus)
 {
     using (var db = new AgnosDBContext())
     {
         return(db.Raw_Material_Form.Where(w => w.Raw_Material_ID == pRawID && w.Status == pSelStatus).FirstOrDefault());
     }
 }
Esempio n. 20
0
 public List <ComboRow> LstWithdrawtransType(bool hasBlank = false)
 {
     using (var db = new AgnosDBContext())
     {
         var clist = new List <ComboRow>();
         if (hasBlank)
         {
             clist.Add(new ComboRow {
                 Value = "", Text = "-"
             });
         }
         clist.Add(new ComboRow()
         {
             Value = Withdraw_Transaction_Type.Withdrawal, Text = Withdraw_Transaction_Type.Withdrawal,
         });
         clist.Add(new ComboRow()
         {
             Value = Withdraw_Transaction_Type.Transfer, Text = Withdraw_Transaction_Type.Transfer
         });
         clist.Add(new ComboRow()
         {
             Value = Withdraw_Transaction_Type.Incoming, Text = Withdraw_Transaction_Type.Incoming
         });
         return(clist);
     }
 }
Esempio n. 21
0
        public List <ComboRow> LstTemplateCode(bool hasBlank = false)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                clist.AddRange(db.Template_Logsheet
                               .Where(w => w.Template_Code != null && w.Record_Status != Record_Status.Delete)
                               .OrderBy(o => o.Template_Code)
                               .Select(s => new ComboRow
                {
                    Value = s.Template_Code.Trim(),
                    Text  = s.Template_Code
                }));

                return(clist);
            }
        }
Esempio n. 22
0
        public List <ComboRow> LstProduct(bool hasBlank = false)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                clist.AddRange(db.CMS_Product
                               .Where(w => w.Record_Status != Record_Status.Delete)
                               .OrderBy(o => o.Product_Code)
                               .Select(s => new ComboRow
                {
                    Value = SqlFunctions.StringConvert((double)s.CMS_Product_ID).Trim(),
                    Text  = s.Product_Code
                }));

                return(clist);
            }
        }
Esempio n. 23
0
        public List <ComboRow> LstTmpField(bool hasBlank = false)
        {
            using (var db = new AgnosDBContext())
            {
                var clist = new List <ComboRow>();

                if (hasBlank)
                {
                    clist.Add(new ComboRow {
                        Value = "", Text = "-"
                    });
                }

                clist.AddRange(db.Template_Field
                               .Where(w => w.Record_Status != Record_Status.Delete)
                               .OrderBy(o => o.Field_Order)
                               .Select(s => new ComboRow
                {
                    Value = SqlFunctions.StringConvert((double)s.Field_ID).Trim(),
                    Text  = s.Field_Name
                }));

                return(clist);
            }
        }
Esempio n. 24
0
 public ServiceResult InsertPageRole(Page_Role pPR)
 {
     try
     {
         using (var db = new AgnosDBContext())
         {
             db.Page_Role.Add(pPR);
             db.SaveChanges();
             db.Entry(pPR).GetDatabaseValues();
             return(new ServiceResult()
             {
                 Code = ReturnCode.SUCCESS,
                 Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                 Field = Resource.Page_Role
             });
         }
     }
     catch (Exception ex)
     {
         return(new ServiceResult()
         {
             Code = ReturnCode.ERROR_INSERT,
             Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
             Field = Resource.Page_Role,
             Exception = ex
         });
     }
 }
Esempio n. 25
0
 public ServiceResult InsertGlobalLookupData(Global_Lookup_Data pData)
 {
     try
     {
         using (var db = new AgnosDBContext())
         {
             db.Global_Lookup_Data.Add(pData);
             db.SaveChanges();
             db.Entry(pData).GetDatabaseValues();
             return(new ServiceResult()
             {
                 Code = ReturnCode.SUCCESS,
                 Msg = Success.GetMessage(ReturnCode.SUCCESS_INSERT),
                 Field = Resource.Global_Lookup
             });
         }
     }
     catch (Exception ex)
     {
         return(new ServiceResult()
         {
             Code = ReturnCode.ERROR_INSERT,
             Msg = Error.GetMessage(ReturnCode.ERROR_INSERT),
             Field = Resource.Global_Lookup,
             Exception = ex
         });
     }
 }
Esempio n. 26
0
        public ServiceResult GetGlobalLookupData(GlobalLookupCriteria cri = null)
        {
            var result = new ServiceResult();

            try
            {
                using (var db = new AgnosDBContext())
                {
                    var rows = db.Global_Lookup_Data
                               .Include(w => w.Global_Lookup_Def)
                               .Where(w => 1 == 1 && w.Record_Status != Record_Status.Delete);

                    if (cri != null)
                    {
                        if (cri.Def_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Def_ID == cri.Def_ID);
                        }
                        if (cri.Lookup_Data_ID.HasValue)
                        {
                            rows = rows.Where(w => w.Lookup_Data_ID == cri.Lookup_Data_ID);
                        }
                    }
                    result.Object = rows.OrderBy(o => o.Lookup_Data_ID).ToList();
                    result.Code   = ReturnCode.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                result.Code      = ReturnCode.ERROR_DB;
                result.Exception = ex;
            }
            return(result);
        }
Esempio n. 27
0
        public ServiceResult ResetPassword(int uID, String PWD)
        {
            using (var db = new AgnosDBContext())
            {
                try
                {
                    var user = getUser(uID);
                    user.PWD = hashSHA256(PWD);

                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    return(new ServiceResult()
                    {
                        Code = ReturnCode.SUCCESS,
                        Msg = Success.GetMessage(ReturnCode.SUCCESS),
                        Field = Resource.Reset_Password
                    });
                }
                catch (Exception ex)
                {
                    return(new ServiceResult()
                    {
                        Code = ReturnCode.ERROR_SAVE,
                        Msg = Error.GetMessage(ReturnCode.ERROR_SAVE),
                        Field = Resource.Reset_Password,
                        Exception = ex
                    });
                }
            }
        }
Esempio n. 28
0
        //public ServiceResult DeleteMaterialMaterialReject(Nullable<int> pMaterialRejectID)
        //{
        //   try
        //   {
        //      using (var db = new AgnosDBContext())
        //      {
        //         var MaterialReject = db.Material_Reject.Where(w => w.Material_Reject_ID == pMaterialRejectID).FirstOrDefault();
        //         if (MaterialReject != null && MaterialReject.Overall_Status != Material_Overall_Status.Closed)
        //         {
        //            db.Material_Reject.Remove(MaterialReject);
        //            db.SaveChanges();
        //         }


        //         return new ServiceResult()
        //         {
        //            Code = ReturnCode.SUCCESS,
        //            Msg = Success.GetMessage(ReturnCode.SUCCESS_DELETE),
        //            Field = Resource.Material_Reject
        //         };
        //      }
        //   }
        //   catch (Exception ex)
        //   {
        //      return new ServiceResult()
        //      {
        //         Code = ReturnCode.ERROR_DELETE,
        //         Msg = Error.GetMessage(ReturnCode.ERROR_DELETE),
        //         Field = Resource.Material_Reject,
        //         Exception = ex
        //      };
        //   }

        //}

        public List <Raw_Material_Attachment> LstRawMaterialAttachment(Nullable <int> pRMID, string PType)
        {
            using (var db = new AgnosDBContext())
            {
                return(db.Raw_Material_Attachment
                       .Where(w => w.Raw_Material_ID == pRMID && w.Attachment_Field == PType && w.Record_Status != Record_Status.Delete).ToList());
            }
        }
Esempio n. 29
0
 public List <ComboRow> LstExchquerWorkOrder(bool hasBlank = false)
 {
     using (var db = new AgnosDBContext())
     {
         var clist = new List <ComboRow>();
         return(clist);
     }
 }
Esempio n. 30
0
        public Activation_Link GetActivationLink(string activationCode)
        {
            using (var db = new AgnosDBContext())
            {
                Activation_Link link = db.Activation_Link
                                       .Where(w => w.Activation_Code.Equals(activationCode))
                                       .FirstOrDefault();

                return(link);
            }
        }