protected void btnSave_Click(object sender, EventArgs e)
        {
            int price = int.Parse(((System.Web.UI.WebControls.WebControl)(sender)).Attributes["priceid"]);

            if (price > 0)
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        PriceBO objPrice = new PriceBO(this.ObjContext);
                        objPrice.ID = price;
                        objPrice.GetObject();

                        objPrice.Remarks      = txtAddNote.Text;
                        objPrice.Modifier     = LoggedUser.ID;
                        objPrice.ModifiedDate = DateTime.Now;
                        ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
                catch (Exception ex)
                {
                    IndicoLogging.log.Error("Error occured while ading/updating note(btnSaveNote_Click()) AddPatternFabricPricePage", ex);
                }
            }
            ViewState["populateaddNewNote"] = false;
            this.PopulatePatternFabrics();
        }
        protected void linkSave_ServerClick(object sender, EventArgs e)
        {
            if (!IsNotRefresh)
            {
                return;
            }
            try
            {
                using (var ts = new TransactionScope())
                {
                    foreach (GridDataItem item in this.RadGridProductionCapacities.Items)
                    {
                        var linkSave = (HtmlAnchor)item.FindControl("linkSave");

                        var txtCapacity = (TextBox)item.FindControl("txtCapacity");

                        var txtHoliydays = (TextBox)item.FindControl("txtHoliydays");

                        var txtNotes = (TextBox)item.FindControl("txtNotes");

                        var txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");

                        var id = int.Parse(((System.Web.UI.HtmlControls.HtmlControl)(linkSave)).Attributes["pcid"].ToString());

                        if (id <= 0)
                        {
                            continue;
                        }
                        var objProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                        {
                            ID = id
                        };
                        objProductionCapacity.GetObject();

                        objProductionCapacity.Capacity     = int.Parse(txtCapacity.Text.Replace(",", string.Empty));
                        objProductionCapacity.NoOfHolidays = (!string.IsNullOrEmpty(txtHoliydays.Text)) ? int.Parse(txtHoliydays.Text) : 0;
                        objProductionCapacity.Notes        = txtNotes.Text;
                        objProductionCapacity.SalesTarget  = Convert.ToDecimal(txtSalesTarget.Text);
                    }

                    ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while updaing Production Capacities Details in ViewProductionCapacities.aspx", ex);
            }

            PopulateDataGrid();
        }
        protected void OnlnkEditCapacityClick(object sender, EventArgs e)
        {
            try
            {
                foreach (GridDataItem item in WeeklyPiecesSummaryRedGrid.Items)
                {
                    var txtCapacity    = (TextBox)item.FindControl("txtCapacity");
                    var txtHolidays    = (TextBox)item.FindControl("txtHolidays");
                    var txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget");

                    var linkEditCapacity = (LinkButton)item.FindControl("linkEditCapacity");
                    var pcid             = int.Parse(linkEditCapacity.Attributes["pcid"]);

                    if (pcid <= 0 || txtCapacity == null || txtHolidays == null)
                    {
                        continue;
                    }
                    using (var ts = new TransactionScope())
                    {
                        var objWeeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                        {
                            ID = pcid
                        };
                        objWeeklyProductionCapacity.GetObject();

                        var capacity = txtCapacity.Text.Replace(",", "");

                        objWeeklyProductionCapacity.Capacity     = int.Parse(capacity);
                        objWeeklyProductionCapacity.NoOfHolidays = int.Parse(txtHolidays.Text);
                        objWeeklyProductionCapacity.SalesTarget  = decimal.Parse(txtSalesTarget.Text);

                        ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occurred while editing weekly capacity and weekly holidays in ViewWeeklyCpacities.aspx", ex);
            }
            PopulateDataGrid();
        }
Пример #4
0
        private void ChangeOrderStatus(int QuoteID)
        {
            try
            {
                if (QuoteID > 0)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        QuoteBO objQuote = new QuoteBO(this.ObjContext);
                        objQuote.ID = QuoteID;
                        objQuote.GetObject();

                        objQuote.Status = 4;

                        ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                IL.log.Error("Error occured while updating quote table in CheckQuote", ex);
            }
        }
Пример #5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int invoiceID = int.Parse(hdnSelectedID.Value.Trim());

            if (invoiceID > 0)
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        InvoiceBO objInvoice = new InvoiceBO(ObjContext);
                        objInvoice.ID = invoiceID;
                        objInvoice.GetObject();

                        List <InvoiceOrderBO> lstInvoiceOrder = (new InvoiceOrderBO()).GetAllObject().Where(o => o.Invoice == objInvoice.ID).ToList();
                        foreach (InvoiceOrderBO objDelInvoiceOrder in lstInvoiceOrder)
                        {
                            InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(ObjContext);
                            objInvoiceOrder.ID = objDelInvoiceOrder.ID;
                            objInvoiceOrder.GetObject();

                            objInvoiceOrder.Delete();
                        }

                        objInvoice.Delete();
                        ObjContext.SaveChanges();
                        ts.Complete();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                PopulateDataGrid();
            }
        }
        private int ProcessForm()
        {
            int distributor = 0;

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    CompanyBO objDistributor = new CompanyBO(this.ObjContext);
                    if (this.QueryID > 0)
                    {
                        objDistributor.ID = this.QueryID;
                        objDistributor.GetObject();
                    }
                    else
                    {
                        objDistributor.Creator     = this.LoggedUser.ID;
                        objDistributor.CreatedDate = DateTime.Now;
                        objDistributor.IsActive    = true;
                        objDistributor.IsDelete    = false;
                    }
                    objDistributor.Modifier     = this.LoggedUser.ID;
                    objDistributor.ModifiedDate = DateTime.Now;

                    objDistributor.Type          = 4; //Distributor
                    objDistributor.IsDistributor = true;
                    objDistributor.Name          = this.txtName.Text;
                    objDistributor.NickName      = this.txtNickName.Text;
                    objDistributor.Number        = this.txtCompanyNumber.Text;
                    objDistributor.Address1      = this.txtAddress1.Text;
                    objDistributor.Address2      = this.txtAddress2.Text;
                    objDistributor.City          = this.txtCity.Text;
                    objDistributor.State         = this.txtState.Text;
                    objDistributor.Postcode      = this.txtPostalCode.Text;
                    objDistributor.Country       = int.Parse(this.ddlCountry.SelectedValue);
                    objDistributor.Phone1        = this.txtPhoneNo1.Text;
                    objDistributor.Phone2        = this.txtPhoneNo2.Text;
                    objDistributor.Fax           = this.txtFaxNo.Text;
                    //objDistributor.Email = this.txtEmailAddress.Text;
                    objDistributor.Coordinator = int.Parse(ddlCoordinator.SelectedValue);
                    //objDistributor.SecondaryCoordinator = int.Parse(this.ddlSecondaryCoordinator.SelectedValue);
                    objDistributor.IsBackOrder = this.chkBackOrder.Checked;
                    objDistributor.IsActive    = this.chkIsActive.Checked;



                    ObjContext.SaveChanges();

                    //distributor = objDistributor.ID;

                    //var objDca = new DistributorClientAddressBO()
                    //{
                    //    CompanyName = "TBA",
                    //    Address = "TBA",
                    //    Suburb = "TBA",
                    //    PostCode = "TBA",
                    //    Country = 14,
                    //    ContactName = "TBA",
                    //    ContactPhone = "TBA",
                    //    State = "TBA",
                    //    EmailAddress = "TBA",
                    //    AddressType = 0,
                    //    Distributor = objDistributor.ID,
                    //    IsAdelaideWarehouse = false
                    //};

                    //objDca.Add();

                    //ObjContext.SaveChanges();

                    //UserBO objUser = null;
                    //if (this.QueryID == 0)
                    //{
                    //    objUser = new UserBO(this.ObjContext);
                    //    objUser.Company = distributor;

                    //    objUser.IsDistributor = true;
                    //    objUser.Status = 3; //Invited
                    //    objUser.Username = this.txtEmailAddress.Text;
                    //    objUser.Password = UserBO.GetNewEncryptedRandomPassword();
                    //    objUser.GivenName = this.txtGivenName.Text;
                    //    objUser.FamilyName = this.txtFamilyName.Text;
                    //    objUser.EmailAddress = this.txtEmailAddress.Text;
                    //    objUser.Creator = this.LoggedUser.ID;
                    //    objUser.CreatedDate = DateTime.Now;
                    //    objUser.HomeTelephoneNumber = this.txtPhoneNo1.Text;
                    //    objUser.OfficeTelephoneNumber = this.txtPhoneNo2.Text;
                    //    objUser.Modifier = this.LoggedUser.ID;
                    //    objUser.ModifiedDate = DateTime.Now;
                    //    objUser.Guid = Guid.NewGuid().ToString();

                    //    RoleBO objRole = new RoleBO(this.ObjContext);
                    //    objRole.ID = 10; // Distributor Administrator
                    //    objRole.GetObject();

                    //    objUser.UserRolesWhereThisIsUser.Add(objRole);
                    //    objUser.CompanysWhereThisIsOwner.Add(objDistributor);

                    //    this.ObjContext.SaveChanges();

                    //    //Send Invitation Email
                    //    string hosturl = IndicoConfiguration.AppConfiguration.SiteHostAddress + "/";
                    //    string emailcontent = String.Format("<p>A new acoount set up for u at <a href =\"http://{0}\">\"http://{0}/</a></p>" +
                    //                                        "<p>To complete your registration simply clik the link below to sign in<br>" +
                    //                                        "<a href=\"http://{0}Welcome.aspx?guid={1}&id={2}\">http://{0}Welcome.aspx?guid={1}&id={2}</a></p>",
                    //                                        hosturl, objUser.Guid, objUser.ID.ToString());

                    //    IndicoEmail.SendMailNotifications(this.LoggedUser, objUser, "Activate Your New Account", emailcontent);
                    //}
                    //else
                    //{
                    //    if (!objDistributor.Name.Contains("BLACKCHROME"))
                    //    {
                    //        objUser = new UserBO(this.ObjContext);
                    //        objUser.ID = (int)objDistributor.Owner;
                    //        objUser.GetObject();

                    //        objUser.GivenName = this.txtGivenName.Text;
                    //        objUser.FamilyName = this.txtFamilyName.Text;
                    //        objUser.EmailAddress = this.txtEmailAddress.Text;

                    //        ObjContext.SaveChanges();
                    //    }
                    //}
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occured while send Distributor email", ex);
            }

            return(distributor);
        }
        private void AddNextYear()
        {
            using (var scope = new TransactionScope())
            {
                var currentYear = DateTime.Now.Year;

                var currentWeeks = new WeeklyProductionCapacityBO(ObjContext).GetAllObject();
                if (currentWeeks.Any())
                {
                    if (currentWeeks.Count > 1)
                    {
                        var lastWeek = currentWeeks.OrderBy(w => w.WeekendDate).Last().WeekendDate;
                        currentYear = lastWeek.Year == currentWeeks[currentWeeks.Count() - 2].WeekendDate.Year ?
                                      lastWeek.AddYears(1).Year : lastWeek.Year;
                    }
                    else
                    {
                        currentYear = currentWeeks.Last().WeekendDate.AddYears(1).Year;
                    }
                }
                var currentYearStartDate = new DateTime(currentYear, 1, 1);
                while (currentYearStartDate.DayOfWeek != DayOfWeek.Tuesday)
                {
                    currentYearStartDate = currentYearStartDate.AddDays(1);
                }
                var weekNumber = 1;
                while (currentYearStartDate.Year == currentYear)
                {
                    var weeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext)
                    {
                        WeekNo = weekNumber, WeekendDate = currentYearStartDate, SalesTarget = 0, HoursPerDay = (decimal)10.0, NoOfHolidays = 6, OrderCutOffDate = currentYearStartDate.AddDays(-18), EstimatedDateOfDespatch = currentYearStartDate, EstimatedDateOfArrival = currentYearStartDate.AddDays(3)
                    };

                    weeklyProductionCapacity.Add();

                    var polodetails = new WeeklyProductionCapacityDetailsBO(ObjContext)
                    {
                        ItemType = 1, TotalCapacity = 5850, FivePcsCapacity = 100, SampleCapacity = 200, Workers = 65, Efficiency = (decimal)0.45
                    };
                    var outerwaredetails = new WeeklyProductionCapacityDetailsBO(ObjContext)
                    {
                        ItemType = 2, TotalCapacity = 450, FivePcsCapacity = 10, SampleCapacity = 20, Workers = 15, Efficiency = (decimal)0.25
                    };
                    weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(polodetails);
                    weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(outerwaredetails);
                    currentYearStartDate = currentYearStartDate.AddDays(7);
                    weekNumber++;
                }
                ObjContext.SaveChanges();
                scope.Complete();
            }
            PopulateDataGrid();


            //try
            //{
            //    using (var ts = new TransactionScope())
            //    {
            //        var currentYear = DateTime.Now.Year.ToString();
            //        bool isLeap = false;


            //        List<WeeklyProductionCapacityBO> lstWeeklyProdCap = (new WeeklyProductionCapacityBO()).SearchObjects();
            //        if (lstWeeklyProdCap.Count > 0)
            //        {
            //            currentYear = lstWeeklyProdCap.Last().WeekendDate.AddYears(1).Year.ToString();
            //        }

            //        DateTime dFirst = DateTime.Parse("01 / 01 /" + currentYear);
            //        DateTime dLast = DateTime.Parse("31 / 12 /" + currentYear);

            //        if ((int.Parse(currentYear) % 4 == 0) && (int.Parse(currentYear) % 100 != 0) || (int.Parse(currentYear) % 400 == 0))
            //        {
            //            isLeap = true;
            //        }

            //        int weekCount = (isLeap == true) ? this.GetWeeksInYear(int.Parse(currentYear), dLast) : int.Parse((dLast.Subtract(dFirst).Days / 7).ToString());
            //        //int id = this.GetWeeksInYear(int.Parse(currentYear), dLast);

            //        DateTime firstTuesday = dFirst;

            //        while (firstTuesday.DayOfWeek != DayOfWeek.Tuesday)
            //        {
            //            firstTuesday = firstTuesday.AddDays(1);
            //        }

            //        for (int i = 1; i <= weekCount; i++)
            //        {
            //            WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext);
            //            objProductionCapacity.WeekNo = i;
            //            objProductionCapacity.WeekendDate = firstTuesday;
            //            objProductionCapacity.Capacity = 0;
            //            objProductionCapacity.Add();

            //            firstTuesday = firstTuesday.AddDays(7);
            //        }

            //        this.ObjContext.SaveChanges();
            //        ts.Complete();
            //    }
            //}
            //catch (Exception)
            //{
            //    //ignored
            //}
        }
        private void ProcessForm(int queryId, bool isDelete)
        {
            try
            {
                using (var ts = new TransactionScope())
                {
                    var objProductionCapacity = new WeeklyProductionCapacityBO(ObjContext);
                    if (queryId > 0)
                    {
                        objProductionCapacity.ID = queryId;
                        objProductionCapacity.GetObject();
                    }
                    if (isDelete)
                    {
                        objProductionCapacity.Delete();
                    }

                    else
                    {
                        objProductionCapacity.NoOfHolidays            = int.Parse(txtWorkingDays.Text);
                        objProductionCapacity.HoursPerDay             = decimal.Parse(txtWorkingHours.Text);
                        objProductionCapacity.OrderCutOffDate         = DateTime.Parse(txtOrderCutOffDate.Text);
                        objProductionCapacity.EstimatedDateOfDespatch = DateTime.Parse(txtETD.Text);
                        objProductionCapacity.EstimatedDateOfArrival  = DateTime.Parse(txtETA.Text);
                        objProductionCapacity.Notes       = txtNotes.Text;
                        objProductionCapacity.SalesTarget = decimal.Parse(txtSalesTaget.Text);

                        foreach (RepeaterItem rptItem in rptItemTypes.Items)
                        {
                            var hdnProdCapDetailID = (HiddenField)rptItem.FindControl("hdnProdCapDetailID");
                            var hdnItemTypeID      = (HiddenField)rptItem.FindControl("hdnItemTypeID");
                            var txtTotalCapacity   = (TextBox)rptItem.FindControl("txtTotalCapacity");
                            var txt5PcsCapacity    = (TextBox)rptItem.FindControl("txt5PcsCapacity");
                            var txtSampleCapacity  = (TextBox)rptItem.FindControl("txtSampleCapacity");
                            var txtWorkers         = (TextBox)rptItem.FindControl("txtWorkers");
                            var txtEfficiency      = (TextBox)rptItem.FindControl("txtEfficiency");
                            var objProdCapDetailBO = new WeeklyProductionCapacityDetailsBO(ObjContext);
                            if (int.Parse(hdnProdCapDetailID.Value) > 0)
                            {
                                objProdCapDetailBO.ID = int.Parse(hdnProdCapDetailID.Value);
                                objProdCapDetailBO.GetObject();
                            }
                            else
                            {
                                objProdCapDetailBO.WeeklyProductionCapacity = queryId;
                                objProdCapDetailBO.ItemType = int.Parse(hdnItemTypeID.Value);
                            }
                            objProdCapDetailBO.TotalCapacity   = int.Parse(txtTotalCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.FivePcsCapacity = int.Parse(txt5PcsCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.SampleCapacity  = int.Parse(txtSampleCapacity.Text) * objProductionCapacity.NoOfHolidays;
                            objProdCapDetailBO.Workers         = int.Parse(txtWorkers.Text);
                            objProdCapDetailBO.Efficiency      = decimal.Parse(txtEfficiency.Text);
                        }
                        if (queryId == 0)
                        {
                            objProductionCapacity.Add();
                        }
                    }
                    ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                IndicoLogging.log.Error("Error occurred while Adding or Editing  or Deleting  the details in Production Capacity", ex);
            }
        }
Пример #9
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int    id   = int.Parse(hdnSelectedID.Value);
            string type = this.hdnType.Value;

            if (type == "distributor")
            {
                PriceListDownloadsBO objPriceListDownload = new PriceListDownloadsBO(this.ObjContext);
                objPriceListDownload.ID = id;
                objPriceListDownload.GetObject();

                string filePath = String.Format("{0}{1}", (IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\PriceLists\"), objPriceListDownload.FileName);

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);

                    try
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            objPriceListDownload.Delete();
                            ObjContext.SaveChanges();
                            ts.Complete();
                        }
                    }
                    catch (Exception ex)
                    {
                        IndicoLogging.log.Error("Error occured while deleting distrinutor price list", ex);
                    }
                }
            }
            if (type == "label")
            {
                LabelPriceListDownloadsBO objLabelPriceListDownload = new LabelPriceListDownloadsBO(this.ObjContext);
                objLabelPriceListDownload.ID = id;
                objLabelPriceListDownload.GetObject();

                string filePath = String.Format("{0}{1}", (IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\PriceLists\"), objLabelPriceListDownload.FileName);

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);

                    try
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            objLabelPriceListDownload.Delete();
                            ObjContext.SaveChanges();
                            ts.Complete();
                        }
                    }
                    catch (Exception ex)
                    {
                        IndicoLogging.log.Error("Error occured while deleting label price list", ex);
                    }
                }
            }
            this.PopulateControls();
        }