Ejemplo n.º 1
0
        public SupplierAEForm(SupplierObject ob)
        {
            supplier = ob;

            InitializeComponent();

            this.bindingSource.DataSource = supplier;

            this.cbx_class.DataSource = SupplierClassManager.SupplierClassList;
            this.cbx_class.DisplayMember = "Name";
            this.cbx_class.ValueMember = "Id";
            this.cbx_class.SelectedValue = 0;
            this.cbx_class.Text = string.Empty;
        }
Ejemplo n.º 2
0
        public ActionResult AddSupplier(SupplierObject supplier)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateSupplier(supplier);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    supplier.DateJoined = DateTime.Now;
                    var k = new SupplierServices().AddSupplier(supplier);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        public bool UpdateSupplier(SupplierObject SupComp)
        {
            SqlParameter[] params_ = new SqlParameter[] {
                new SqlParameter("@Id", SupComp.Id),
                new SqlParameter("@Code", SupComp.Code),
                new SqlParameter("@Name", SupComp.Name),
                new SqlParameter("@Email", SupComp.Email),
                new SqlParameter("@ContactNumber", SupComp.ContactNbr),
                new SqlParameter("@UnitNumber", SupComp.UnitNbr),
                new SqlParameter("@StreetName", SupComp.StreetName),
                new SqlParameter("@Municipality", SupComp.Municipality),
                new SqlParameter("@City", SupComp.City),
                new SqlParameter("@Country", SupComp.Country),
                new SqlParameter("@ZipCode", SupComp.Zip),
                new SqlParameter("@DateCreated", SupComp.DateAdded),
                new SqlParameter("@AddedBy", SupComp.AddedBy),
                new SqlParameter("@ImpexRefNbr", SupComp.ImpexRefNbr),
                new SqlParameter("@IP", Helpers.CustomHelper.GetLocalIPAddress()),
                new SqlParameter("@MAC", Helpers.CustomHelper.GetMACAddress()),
            };

            return(Library.ConnectionString.returnCon.executeQuery("spUpdateSupplierCompany", params_, CommandType.StoredProcedure));
        }
Ejemplo n.º 4
0
 void IEditableObject.EndEdit()
 {
     try
     {
         if (_inTxn)
         {
             _loadedMaterialCategory    = MaterialCategory;
             _loadedMaterialType        = MaterialType;
             _loadedMaterialSubType     = MaterialSubType;
             _loadedEmployeeCreator     = EmployeeCreator;
             _loadedEmployeeResponsable = EmployeeResponsable;
             _loadedVehicle             = Vehicle;
             _loadedSupplier            = Supplier;
             _loadedName                 = Name;
             _loadedDescription          = Description;
             _loadedType                 = Type;
             _loadedSerieNumber          = SerieNumber;
             _loadedInternalNumber       = InternalNumber;
             _loadedPurchasedOn          = PurchasedOn;
             _loadedPrice                = Price;
             _loadedNextMaintenance      = NextMaintenance;
             _loadedMaintenanceFrequency = MaintenanceFrequency;
             _loadedActive               = Active;
             _loadedBroken               = Broken;
             //Child members
             _loadedMemos        = Memos;
             _loadedMaintenances = Maintenances;
             _inTxn = true;
         }
     }
     catch (Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 5
0
        public Dictionary <string, object> UploadTargets(string path_and_file)
        {
            try
            {
                //variable for logs
                int success = 0;
                int fail    = 0;
                int total   = 0;

                //get current workweek and year
                //di ko sure kung kailangan to
                //List<int> curr_ww = workweek_helper.GetCurrentWorkWeek();
                //int current_workweek = curr_ww[0];
                //int current_year = curr_ww[1];

                response = new Dictionary <string, object>();
                //kailangan ko to
                SupplierModels t = new SupplierModels();

                FileStream       stream      = File.Open(path_and_file, FileMode.Open, FileAccess.Read);
                IExcelDataReader excelReader = null;
                string           ext         = Path.GetExtension(stream.Name);
                if (ext == ".xls")
                {
                    //1. Reading from a binary Excel file ('97-2003 format; *.xls)
                    excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
                }
                else if (ext == ".xlsx")
                {
                    //2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
                    excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                }
                else
                {
                    throw new Exception("Invalid file type.");
                }

                //Choose one of either 3, 4, or 5
                //3. DataSet - The result of each spreadsheet will be created in the result.Tables
                //DataSet result = excelReader.AsDataSet();

                //4. DataSet - Create column names from first row
                excelReader.IsFirstRowAsColumnNames = true;
                DataSet result = excelReader.AsDataSet();

                //5. Data Reader methods
                DateTime dateCreated = DateTime.Now;
                int      ctr         = 0;
                string   log_output  = "";

                ////override function
                //if (allowOverride)
                //{
                //    t.DeleteTestTargets("WW" + current_workweek.ToString().PadLeft(2, '0'), current_year);
                //}

                while (excelReader.Read())
                {
                    if (ctr >= 1)
                    {
                        SupplierObject targets = new SupplierObject();

                        targets.Name         = excelReader.IsDBNull(0) ? string.Empty : excelReader.GetString(0);
                        targets.Email        = excelReader.IsDBNull(1) ? string.Empty : excelReader.GetString(1);
                        targets.ContactNbr   = excelReader.IsDBNull(2) ? string.Empty : excelReader.GetString(2);
                        targets.UnitNbr      = excelReader.IsDBNull(3) ? string.Empty : excelReader.GetString(3);
                        targets.StreetName   = excelReader.IsDBNull(4) ? string.Empty : excelReader.GetString(4);
                        targets.Municipality = excelReader.IsDBNull(5) ? string.Empty : excelReader.GetString(5);
                        targets.City         = excelReader.IsDBNull(6) ? string.Empty : excelReader.GetString(6);
                        targets.Country      = excelReader.IsDBNull(7) ? string.Empty : excelReader.GetString(7);
                        targets.Zip          = excelReader.IsDBNull(8) ? 0 : Convert.ToInt32(excelReader.GetString(8));
                        targets.ImpexRefNbr  = excelReader.IsDBNull(9) ? string.Empty : excelReader.GetString(9);
                        targets.IsActive     = true;
                        targets.AddedBy      = Convert.ToInt32(HttpContext.Current.Session["userId_local"]);
                        targets.DateAdded    = dateCreated;


                        t.SaveNewSupplier(targets);
                        total++;
                        success++;
                        //buburahin ko to titira ko lang "t.SaveTargets(targets)"
                        //if (targets.WorkWeek != "WW" + current_workweek.ToString().PadLeft(2, '0') || targets.FiscalYear != current_year)
                        //{
                        //    fail++;
                        //    log_output += "<p><span class='label label-danger'>[" + targets.ProductGroup + "] [" + targets.PackageGroupA + "] [" + targets.PackageGroupB + "] [" + targets.Target + "] [" + targets.WorkWeek + "] [" + targets.FiscalYear + "] = work week or year mismatch</span></p>";
                        //}
                        //else
                        //{
                        //    if (t.CheckExistingTestTarget(targets) > 0)
                        //    {
                        //        fail++;
                        //        log_output += "<p><span class='label label-danger'>[" + targets.ProductGroup + "] [" + targets.PackageGroupA + "] [" + targets.PackageGroupB + "] [" + targets.Target + "] [" + targets.WorkWeek + "] [" + targets.FiscalYear + "] = already exists</span></p>";
                        //    }
                        //    else
                        //    {
                        //        if (!t.SaveTargets(targets))
                        //        {
                        //            fail++;
                        //            log_output += "<p><span class='label label-danger'>[" + targets.ProductGroup + "] [" + targets.PackageGroupA + "] [" + targets.PackageGroupB + "] [" + targets.Target + "] [" + targets.WorkWeek + "] [" + targets.FiscalYear + "] = failed</span></p>";
                        //        }
                        //        else
                        //        {
                        //            hasSuccess = true;
                        //            success++;
                        //            log_output += "<p><span class='label label-success'>[" + targets.ProductGroup + "] [" + targets.PackageGroupA + "] [" + targets.PackageGroupB + "] [" + targets.Target + "] [" + targets.WorkWeek + "] [" + targets.FiscalYear + "] = added</span></p>";
                        //        }
                        //    }
                        //}
                        //hanggang dito
                        //total++;
                    }

                    ctr++;
                }

                //if (hasSuccess)
                //{
                //    t.RefreshData();
                //}

                //6. Free resources (IExcelDataReader is IDisposable)
                excelReader.Close();

                Dictionary <string, int> stats = new Dictionary <string, int>();
                stats.Add("success", success);
                stats.Add("fail", fail);

                Dictionary <string, string> msg = new Dictionary <string, string>();

                if (total <= 0)
                {
                    throw new Exception("Uploaded file is empty or is in the wrong format. Kindly check the guidelines for uploading.");
                }
                else
                {
                    if (success == total)
                    {
                        msg.Add("title", "Uploading Successful!");
                        msg.Add("body", "New targets uploaded successfully!");
                        msg.Add("type", "success");
                    }
                    else
                    {
                        msg.Add("title", "Uploading Unsuccessful!");
                        msg.Add("body", success + " / " + total + " uploaded successfully!");
                        msg.Add("type", "danger");
                    }
                }

                response.Add("success", true);
                response.Add("error", false);
                response.Add("stats", stats);
                response.Add("logs", log_output);
                response.Add("message", msg);
            }
            catch (Exception e)
            {
                response.Add("success", false);
                response.Add("error", true);
                response.Add("message", e.ToString());
            }

            return(response);
        }