Example #1
0
        public string ExportInventoryReportDetail(int userID, int factoryWarehouseID, int?productionTeamID, string startDate, string endDate, out Library.DTO.Notification notification)
        {
            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            string fileName = string.Empty;

            InventoryDataObject ds = new InventoryDataObject();

            try
            {
                //// Get company.
                //Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory();
                //int? companyID = fwFactory.GetCompanyID(userID);

                //// Get factory warehouse.
                //int? factoryWID = (factoryWarehouseID <= 0) ? (int?)null : factoryWarehouseID;
                //int? productionTID = (productionTeamID <= 0) ? (int?)null : productionTeamID;

                //System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter();
                //adap.SelectCommand = new System.Data.SqlClient.SqlCommand("InventoryRpt_function_ExportExcel", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                //adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                //adap.SelectCommand.Parameters.AddWithValue("@companyID", companyID);
                //adap.SelectCommand.Parameters.AddWithValue("@factoryWarehouseID", factoryWID);
                //adap.SelectCommand.Parameters.AddWithValue("@productionTeamID", productionTID);
                //adap.SelectCommand.Parameters.AddWithValue("@startDate", startDate);
                //adap.SelectCommand.Parameters.AddWithValue("@endDate", endDate);
                //adap.TableMappings.Add("Table", "WarehouseData");
                //adap.TableMappings.Add("Table1", "InventoryData");
                //adap.TableMappings.Add("Table2", "InventoryDetailData");
                //adap.Fill(ds);

                //InventoryDataObject.CommonDataRow hRow = ds.CommonData.NewCommonDataRow();
                //hRow.ReportDate = DateTime.Now.ToString("dd/MM/yyyy");
                //hRow.StartDate = startDate;
                //hRow.EndDate = endDate;
                //hRow.FactoryWarehouseID = factoryWarehouseID;
                //ds.CommonData.AddCommonDataRow(hRow);

                //ds.Tables.Remove("InventoryRpt_Inventory_View");
                //ds.Tables.Remove("InventoryRpt_InventoryDetail_View");

                //ds.AcceptChanges();

                //fileName = Library.Helper.CreateReportFileWithEPPlus2(ds, "InventoryDetail");
            }
            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(fileName);
        }
Example #2
0
        /// <summary>
        /// Inventories the item popup.
        /// </summary>
        /// <returns>The item popup.</returns>
        /// <param name="_control">Control.</param>
        /// <param name="_title">Title.</param>
        /// <param name="_hint">Hint.</param>
        /// <param name="_name">Name.</param>
        /// <param name="_help">Help.</param>
        public static string InventoryItemPopup(ICECreatureControl _control, string _title, string _hint, string _name, string _help = "")
        {
            if (_control == null)
            {
                return("");
            }

            InventoryDataObject _inventory = _control.Creature.Status.Inventory;

            if (_inventory == null || _inventory.Slots.Count == 0)
            {
                EditorGUILayout.LabelField(_title + " (- no reference item - check register!)");
                return("");
            }
            else
            {
                List <string> _keys = _inventory.AvailableItems;

                _keys.Insert(0, " ");

                string[] _names = new string[_keys.Count];

                int _index = 0;
                for (int i = 0; i < _keys.Count; i++)
                {
                    if (_keys[i] == " " && i == 0)
                    {
                        _names[i] = " ";
                    }
                    else if (_keys[i] == " ")
                    {
                        _names[i] = "";
                    }
                    else
                    {
                        _names[i] = _keys[i];
                    }

                    if (_name == _names[i])
                    {
                        _index = i;
                    }
                }

                if (ICE.World.Utilities.SystemTools.FindChildByName(_name, _control.gameObject.transform) != null)
                {
                    GUI.backgroundColor = Color.green;
                }

                if (_title.Trim() != "")
                {
                    _index = ICEEditorLayout.Popup(_title, _hint, _index, _names, _help);
                }
                else
                {
                    _index = EditorGUILayout.Popup(_index, _names);
                }

                GUI.backgroundColor = ICEEditorLayout.DefaultBackgroundColor;

                return(_names[_index].Trim());
            }
        }
Example #3
0
        public string ExportInventoryReport(int userID, int factoryWarehouseID, int?productionTeamID, string startDate, string endDate, out Library.DTO.Notification notification)
        {
            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            string fileName = "";

            try
            {
                Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory();
                int?companyID = frameworkFactory.GetCompanyID(userID);

                int?factoryWID    = (factoryWarehouseID <= 0) ? (int?)null : factoryWarehouseID;
                int?productionTID = (productionTeamID <= 0) ? (int?)null : productionTeamID;

                if (!factoryWID.HasValue && !productionTID.HasValue)
                {
                    notification.Type    = NotificationType.Error;
                    notification.Message = "Please select one Factory Warehouse or one Production Team to search";

                    return(fileName);
                }

                InventoryDataObject ds = new InventoryDataObject();
                System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter();

                if (factoryWID.HasValue)
                {
                    adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("InventoryOverviewRpt_function_ExportInventoryWithFactoryWarehouse", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                    adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    adap.SelectCommand.Parameters.AddWithValue("@FactoryWarehouseID", factoryWID);
                }

                if (productionTID.HasValue)
                {
                    adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("InventoryOverviewRpt_function_ExportInventoryWithProductionTeam", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                    adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                    adap.SelectCommand.Parameters.AddWithValue("@ProductionTeamID", productionTID);
                }

                adap.SelectCommand.Parameters.AddWithValue("@StartDate", startDate);
                adap.SelectCommand.Parameters.AddWithValue("@EndDate", endDate);
                adap.SelectCommand.Parameters.AddWithValue("@CompanyID", companyID);

                adap.TableMappings.Add("Table", "CommonData");
                adap.TableMappings.Add("Table1", "InventoryData");
                adap.TableMappings.Add("Table2", "ClientData");

                adap.Fill(ds);
                //ds.AcceptChanges();
                foreach (var inventoryItem in ds.InventoryData.ToList())
                {
                    var clientUDs = ds.ClientData.Where(o => o.ProductionItemUD == inventoryItem.ProductionItemUD).Select(s => s.ClientUD);
                    if (clientUDs != null && clientUDs.Count() > 0)
                    {
                        inventoryItem.ClientUD = clientUDs.Aggregate((i, j) => i + "," + j);
                    }
                }

                fileName = Library.Helper.CreateReportFileWithEPPlus2(ds, "Inventory");
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(fileName);
        }
Example #4
0
        /// Custom function export data (new version)
        /// FactoryWarehouses: list selected from front-end
        /// ProductionTeamID
        /// StartDate, EndDate
        public object CustomExportDataWithFilter(int userID, Hashtable filters, out Notification notification)
        {
            notification      = new Notification();
            notification.Type = NotificationType.Success;

            string path = null;

            try
            {
                string factoryWarehouses = null;
                int?   productionTeamID  = null;
                string startDate         = null;
                string endDate           = null;
                int?   companyID         = null;

                if (filters.ContainsKey("factoryWarehouses") && filters["factoryWarehouses"] != null && !string.IsNullOrEmpty(filters["factoryWarehouses"].ToString()))
                {
                    factoryWarehouses = filters["factoryWarehouses"].ToString();
                }

                if (filters.ContainsKey("productionTeamID") && filters["productionTeamID"] != null && !string.IsNullOrEmpty(filters["productionTeamID"].ToString()))
                {
                    productionTeamID = (int?)Convert.ToInt32(filters["productionTeamID"].ToString());
                }

                if (filters.ContainsKey("startDate") && filters["startDate"] != null && !string.IsNullOrEmpty(filters["startDate"].ToString()))
                {
                    startDate = filters["startDate"].ToString();
                }

                if (filters.ContainsKey("endDate") && filters["endDate"] != null && !string.IsNullOrEmpty(filters["endDate"].ToString()))
                {
                    endDate = filters["endDate"].ToString();
                }

                if (factoryWarehouses == null && productionTeamID == null)
                {
                    notification.Type    = NotificationType.Error;
                    notification.Message = "Please select factory warehouse or production team!";
                    return(path);
                }

                if (startDate == null || endDate == null)
                {
                    notification.Type    = NotificationType.Error;
                    notification.Message = "Please fill start date and end date!";
                    return(path);
                }

                using (var context = CreateContext())
                {
                    InventoryDataObject ds = new InventoryDataObject();
                    System.Data.SqlClient.SqlDataAdapter adap = new System.Data.SqlClient.SqlDataAdapter();

                    if (!string.IsNullOrEmpty(factoryWarehouses))
                    {
                        adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("InventoryOverviewRpt_function_ExportInventoryWithFactoryWarehouse", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                        adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                        adap.SelectCommand.Parameters.AddWithValue("@factoryWarehouses", factoryWarehouses);
                    }

                    if (productionTeamID.HasValue)
                    {
                        Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory();
                        companyID = fwFactory.GetCompanyID(userID);

                        adap.SelectCommand             = new System.Data.SqlClient.SqlCommand("InventoryOverviewRpt_function_ExportInventoryWithProductionTeam", new System.Data.SqlClient.SqlConnection(Library.Helper.GetSQLConnectionString()));
                        adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
                        adap.SelectCommand.Parameters.AddWithValue("@productionTeamID", productionTeamID);
                        adap.SelectCommand.Parameters.AddWithValue("@companyID", companyID);
                    }

                    adap.SelectCommand.Parameters.AddWithValue("@startDate", startDate);
                    adap.SelectCommand.Parameters.AddWithValue("@endDate", endDate);

                    adap.TableMappings.Add("Table", "CommonData");
                    adap.TableMappings.Add("Table1", "InventoryData");
                    adap.TableMappings.Add("Table2", "ClientData");

                    adap.Fill(ds);

                    foreach (var inventoryItem in ds.InventoryData.ToList())
                    {
                        var clientUDs = ds.ClientData.Where(o => o.ProductionItemUD == inventoryItem.ProductionItemUD).Select(s => s.ClientUD);
                        if (clientUDs != null && clientUDs.Count() > 0)
                        {
                            inventoryItem.ClientUD = clientUDs.Aggregate((i, j) => i + "," + j);
                        }
                    }

                    path = Library.Helper.CreateReportFileWithEPPlus2(ds, "Inventory");
                }
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(path);
        }