예제 #1
0
        public DTO.SearchFormData GetDataWithFilter(int iRequesterID, System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            // keep log entry
            fwBLL.WriteLog(iRequesterID, 0, "get list of Purchasing Invoice");

            // query data
            return(factory.GetDataWithFilter(filters, pageSize, pageIndex, orderBy, orderDirection, out totalRows, out notification));
        }
예제 #2
0
 public override IEnumerable <DTO.WarehouseCIMng.WarehouseCISearch> GetDataWithFilter(int iRequesterID, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     // keep log entry
     fwBLL.WriteLog(iRequesterID, 0, "get list of warehouse ci");
     return(factory.GetDataWithFilter(filters, pageSize, pageIndex, orderBy, orderDirection, out totalRows, out notification));
 }
예제 #3
0
 public override bool DeleteData(int id, int iRequesterID, out Library.DTO.Notification notification)
 {
     // keep log entry
     fwBLL.WriteLog(iRequesterID, 0, "delete warehouse ci " + id.ToString());
     return(factory.DeleteData(id, out notification));
 }
예제 #4
0
 public bool DeleteData(int userId, int id, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
     //return bll.DeleteData(userId, id, out notification);
 }
예제 #5
0
 public object GetInitData(int userId, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
     //return bll.GetInitData(userId, out notification);
 }
예제 #6
0
 public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public override bool Reset(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #8
0
        public DTO.ShippingInstructionMng.ShippingInstruction GetDefault(int clientId, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ShippingInstructionMng.ShippingInstruction data = new DTO.ShippingInstructionMng.ShippingInstruction();

            //try to get data
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    data = converter.DB2DTO_ShippingInstruction(context.ShippingInstructionMng_ShippingInstruction_View.FirstOrDefault(o => o.ClientID == clientId && o.IsDefault.HasValue && o.IsDefault.Value));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
예제 #9
0
        public DTO.ShippingInstructionMng.PODCountry GetCountryFromPODfunction(int podid, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ShippingInstructionMng.PODCountry data = new DTO.ShippingInstructionMng.PODCountry();

            //try to get data
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    data = converter.DB2DTO_PODCountry(context.ShippingInstructionMng_PODCountry_View.FirstOrDefault(o => o.PoDID == podid));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
예제 #10
0
        public override bool UpdateData(int id, ref DTO.ShippingInstructionMng.ShippingInstruction dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    ShippingInstruction dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new ShippingInstruction();
                        context.ShippingInstruction.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.ShippingInstruction.FirstOrDefault(o => o.ShippingInstructionID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "Shipping instruction not found!";
                        return(false);
                    }
                    else
                    {
                        // check concurrency
                        if (dbItem.ConcurrencyFlag != null && !dbItem.ConcurrencyFlag.SequenceEqual(Convert.FromBase64String(dtoItem.ConcurrencyFlag_String)))
                        {
                            throw new Exception(DALBase.Helper.TEXT_CONCURRENCY_CONFLICT);
                        }

                        // reset default
                        if (dtoItem.IsDefault.HasValue && dtoItem.IsDefault.Value)
                        {
                            int        ClientID       = dtoItem.ClientID.Value;
                            List <int> InstructionIDs = context.ShippingInstructionMng_ShippingInstruction_View.Where(o => o.ClientID == ClientID).Select(o => o.ShippingInstructionID).ToList();
                            context.ShippingInstruction.Where(o => InstructionIDs.Contains(o.ShippingInstructionID)).ToList().ForEach(o => o.IsDefault = null);
                        }

                        converter.DTO2DB(dtoItem, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.ShippingInstructionID, out notification).Data;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
예제 #11
0
        public override bool Reset(int id, ref DTO.ShippingInstructionMng.ShippingInstruction dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    ShippingInstruction dbItem = context.ShippingInstruction.FirstOrDefault(o => o.ShippingInstructionID == id);
                    if (dbItem != null)
                    {
                        dbItem.IsConfirmed   = false;
                        dbItem.ConfirmedBy   = null;
                        dbItem.ConfirmedDate = null;
                        dbItem.UpdatedBy     = dtoItem.UpdatedBy;
                        dbItem.UpdatedDate   = DateTime.Now;
                        context.SaveChanges();
                        dtoItem = GetData(id, out notification).Data;

                        return(true);
                    }
                    else
                    {
                        throw new Exception("Shipping instruction not found!");
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }
예제 #12
0
        public override DTO.ShippingInstructionMng.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.ShippingInstructionMng.SearchFormData data = new DTO.ShippingInstructionMng.SearchFormData();
            data.Data = new List <DTO.ShippingInstructionMng.ShippingInstructionSearchResult>();
            totalRows = 0;

            //try to get data
            try
            {
                using (ShippingInstructionMngEntities context = CreateContext())
                {
                    string ClientUD          = null;
                    string ProformaInvoiceNo = null;
                    string Priority          = null;
                    int?   PODID             = null;
                    bool?  IsDefault         = null;
                    bool?  IsSample          = null;

                    if (filters.ContainsKey("ClientUD") && !string.IsNullOrEmpty(filters["ClientUD"].ToString()))
                    {
                        ClientUD = filters["ClientUD"].ToString().Replace("'", "''");
                    }
                    if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString()))
                    {
                        ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''");
                    }
                    if (filters.ContainsKey("PODID") && !string.IsNullOrEmpty(filters["PODID"].ToString()))
                    {
                        PODID = (int)filters["PODID"];
                    }
                    if (filters.ContainsKey("Priority") && !string.IsNullOrEmpty(filters["Priority"].ToString()))
                    {
                        Priority = filters["Priority"].ToString().Replace("'", "''");
                    }
                    if (filters.ContainsKey("IsDefault") && !string.IsNullOrEmpty(filters["IsDefault"].ToString()))
                    {
                        if (filters["IsDefault"].ToString() == "1")
                        {
                            IsDefault = true;
                        }
                        else
                        {
                            IsDefault = false;
                        }
                    }
                    if (filters.ContainsKey("IsSample") && !string.IsNullOrEmpty(filters["IsSample"].ToString()))
                    {
                        if (filters["IsSample"].ToString() == "1")
                        {
                            IsSample = true;
                        }
                        else
                        {
                            IsSample = false;
                        }
                    }

                    totalRows = context.ShippingInstructionMng_function_SearchShippingInstruction(ClientUD, PODID, ProformaInvoiceNo, Priority, IsDefault, IsSample, orderBy, orderDirection).Count();
                    var result = context.ShippingInstructionMng_function_SearchShippingInstruction(ClientUD, PODID, ProformaInvoiceNo, Priority, IsDefault, IsSample, orderBy, orderDirection);

                    data.Data = converter.DB2DTO_ShippingInstructionSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
예제 #13
0
 public DTO.SearchFilterData GetSearchFilter(out Library.DTO.Notification notification)
 {
     return(factory.GetSearchFilter(out notification));
 }
예제 #14
0
 public bool Reset(int iRequesterID, int id, ref object dtoItem, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        public bool UpdateData(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            DTO.FactoryLocation factoryLocation = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.FactoryLocation>();
            bool resultUpdate = false;

            // Check location code is null.
            if (string.IsNullOrEmpty(factoryLocation.LocationUD.Trim()))
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = "Please input Location Code!";

                return(resultUpdate);
            }

            try
            {
                using (var context = CreateContext())
                {
                    Location location = null;

                    if (id < 0)
                    {
                        // Check location code exist.
                        location = context.Location.FirstOrDefault(o => o.LocationUD == factoryLocation.LocationUD);
                        if (location != null)
                        {
                            notification.Type    = Library.DTO.NotificationType.Error;
                            notification.Message = "Location already in database!";

                            return(resultUpdate);
                        }
                        else
                        {
                            location = new Location();
                        }

                        context.Location.Add(location);
                    }
                    else
                    {
                        location = context.Location.FirstOrDefault(o => o.LocationID == id);

                        if (location == null)
                        {
                            notification.Type    = Library.DTO.NotificationType.Error;
                            notification.Message = "Cannot found data!";

                            return(resultUpdate);
                        }
                    }

                    converter.DTO2DB_UpdateData(factoryLocation, ref location);

                    if (id < 0)
                    {
                        location.CreatedBy   = userId;
                        location.CreatedDate = DateTime.Now;
                    }

                    location.UpdatedBy   = userId;
                    location.UpdatedDate = DateTime.Now;

                    location.LocationUD = factoryLocation.LocationUD;

                    context.SaveChanges();

                    dtoItem = converter.DB2DTO_FactoryLocation(context.FactoryLocationMng_Location_View.FirstOrDefault(o => o.LocationID == location.LocationID));

                    resultUpdate = true;
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;

                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
            }

            return(resultUpdate);
        }
예제 #16
0
        public string ExportExcel(System.Collections.Hashtable filters, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            ShippingInstructionMngObject ds = new ShippingInstructionMngObject();

            string ClientUD          = null;
            string ProformaInvoiceNo = null;
            string Priority          = null;
            int?   PODID             = null;
            bool?  IsDefault         = null;
            bool?  IsSample          = null;

            if (filters.ContainsKey("ClientUD") && !string.IsNullOrEmpty(filters["ClientUD"].ToString()))
            {
                ClientUD = filters["ClientUD"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString()))
            {
                ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("PODID") && !string.IsNullOrEmpty(filters["PODID"].ToString()))
            {
                PODID = (int)filters["PODID"];
            }
            if (filters.ContainsKey("Priority") && !string.IsNullOrEmpty(filters["Priority"].ToString()))
            {
                Priority = filters["Priority"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("IsDefault") && !string.IsNullOrEmpty(filters["IsDefault"].ToString()))
            {
                if (filters["IsDefault"].ToString() == "1")
                {
                    IsDefault = true;
                }
                else
                {
                    IsDefault = false;
                }
            }
            if (filters.ContainsKey("IsSample") && !string.IsNullOrEmpty(filters["IsSample"].ToString()))
            {
                if (filters["IsSample"].ToString() == "1")
                {
                    IsSample = true;
                }
                else
                {
                    IsSample = false;
                }
            }

            try
            {
                System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter();
                adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("ShippingInstructionMng_Function_ExportExcelWithFilter", new System.Data.SqlClient.SqlConnection(DALBase.Helper.GetSQLConnectionString()));
                adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;

                adap.SelectCommand.Parameters.AddWithValue("ClientUD", ClientUD);
                adap.SelectCommand.Parameters.AddWithValue("ProformaInvoiceNo", ProformaInvoiceNo);
                adap.SelectCommand.Parameters.AddWithValue("Priority", Priority);
                adap.SelectCommand.Parameters.AddWithValue("IsDefault", IsDefault);
                adap.SelectCommand.Parameters.AddWithValue("IsSample", IsSample);

                adap.TableMappings.Add("Table", "ShippingInstructionMng_ShippingInstructionExportExcel_View");
                adap.Fill(ds);
                ds.AcceptChanges();

                return(Library.Helper.CreateReportFileWithEPPlus(ds, "ShippingInstructionRpt"));
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(string.Empty);
            }
        }
예제 #17
0
 public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #18
0
 public object GetDataWithFilter(int userId, System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #19
0
 public override bool DeleteData(int id, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #20
0
 public object GetData(int userId, int id, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #21
0
 public object GetDataWithFilter(int userId, System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     return(bll.GetDataWithFilter(userId, filters, pageSize, pageIndex, orderBy, orderDirection, out totalRows, out notification));
 }
예제 #22
0
 public bool Approve(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
 }
예제 #23
0
 public bool Reset(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
 {
     throw new NotImplementedException();
     //return bll.Reset(userId, id, ref dtoItem, out notification);
 }
예제 #24
0
 public object GetInitData(int userId, out Library.DTO.Notification notification)
 {
     return(bll.GetInitData(userId, out notification));
 }
예제 #25
0
        public object CustomFunction(int userId, string identifier, System.Collections.Hashtable filters, out Library.DTO.Notification notification)
        {
            switch (identifier.ToLower())
            {
            case "getdeliverynotelist":
                return(bll.GetDetailProductionItemList(userId, filters, out notification));

            case "getdeliverynoteprintouthtml":
                return(bll.GetDeliveryNotePrintoutHTML(userId, filters, out notification));
            }
            notification = new Library.DTO.Notification {
                Type = Library.DTO.NotificationType.Error, Message = "Custom function's identifier not matched"
            };
            return(null);
        }
예제 #26
0
        public object CustomFunction(int userId, string identifier, System.Collections.Hashtable input, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            switch (identifier.Trim().ToLower())
            {
            case "getexcelreport":
                if (input.ContainsKey("Season"))
                {
                    return(bll.GetExcelReportData(userId, input["Season"].ToString(), out notification));
                }
                else
                {
                    notification.Message = "unknow season";
                    notification.Type    = Library.DTO.NotificationType.Error;
                }
                break;

            case "gethtmlreport":
                if (input.ContainsKey("Season"))
                {
                    return(bll.GetHtmlReportData(userId, input["Season"].ToString(), out notification));
                }
                else
                {
                    notification.Message = "unknow season";
                    notification.Type    = Library.DTO.NotificationType.Error;
                }
                break;

            case "get-admin-dashboard":
                if (input.ContainsKey("season"))
                {
                    return(bll.GetSalePerformance(userId, input["season"].ToString(), out notification));
                }
                else
                {
                    notification.Message = "unknow season";
                    notification.Type    = Library.DTO.NotificationType.Error;
                }
                break;

            default:
                notification.Message = "function identifier do not match";
                notification.Type    = Library.DTO.NotificationType.Error;
                break;
            }
            return(null);
        }
예제 #27
0
 public override DTO.WarehouseCIMng.WarehouseCI GetData(int id, int iRequesterID, out Library.DTO.Notification notification)
 {
     // keep log entry
     fwBLL.WriteLog(iRequesterID, 0, "get warehouse ci " + id.ToString());
     return(factory.GetData(id, out notification));
 }
예제 #28
0
        public DTO.SearchForm GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            totalRows = 0;

            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            DTO.SearchForm data = new DTO.SearchForm();
            data.FactoryLocations = new List <DTO.FactoryLocation>();

            try
            {
                using (var context = CreateContext())
                {
                    string locationUD            = filters.ContainsKey("locationUD") && filters["locationUD"] != null && !string.IsNullOrEmpty(filters["locationUD"].ToString().Replace("'", "''")) ? filters["locationUD"].ToString().Trim() : null;
                    string locationNM            = filters.ContainsKey("locationNM") && filters["locationNM"] != null && !string.IsNullOrEmpty(filters["locationNM"].ToString().Replace("'", "''")) ? filters["locationNM"].ToString().Trim() : null;
                    int?   manufacturerCountryID = filters.ContainsKey("manufacturerCountryID") && filters["manufacturerCountryID"] != null && !string.IsNullOrEmpty(filters["manufacturerCountryID"].ToString().Replace("'", "''")) ? (int?)Convert.ToInt32(filters["manufacturerCountryID"].ToString().Trim()) : null;

                    totalRows             = context.FactoryLocationMng_function_LocationSearchResult(locationUD, locationNM, manufacturerCountryID, orderBy, orderDirection).Count();
                    data.FactoryLocations = converter.DB2DTO_FactoryLocationSearchResult(context.FactoryLocationMng_function_LocationSearchResult(locationUD, locationNM, manufacturerCountryID, orderBy, orderDirection).ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;

                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
            }

            return(data);
        }
예제 #29
0
 public override bool UpdateData(int id, ref DTO.WarehouseCIMng.WarehouseCI dtoItem, int iRequesterID, out Library.DTO.Notification notification)
 {
     // keep log entry
     fwBLL.WriteLog(iRequesterID, 0, "update warehouse ci " + id.ToString());
     dtoItem.UpdatedBy = iRequesterID;
     return(factory.UpdateData(id, ref dtoItem, out notification));
 }
예제 #30
0
 public bool CreateReturnData(object dtoItem, out Library.DTO.Notification notification)
 {
     DAL.DataFactoryReturnGoods factory = new DAL.DataFactoryReturnGoods();
     return(factory.CreateReturnData(dtoItem, out notification));
 }