示例#1
0
 public CarRentalService()
 {
     repository      = new Repository();
     bookingMethods  = new BookingMethods(repository);
     carMethods      = new CarMethods(repository);
     customerMethods = new CustomerMethods(repository);
 }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CustomerMethods cm = new CustomerMethods();

            GridView1.DataSource = cm.ViewJoin();
            GridView1.DataBind();
        }
示例#3
0
        public ActionResult Customer()
        {
            if (string.IsNullOrEmpty((string)Session["DealerCode"]))
            {
                return(RedirectToAction("NewLogin", "Home"));
            }
            if (common.UserRight("2502", "001"))
            {
                dealerCode = Session["DealerCode"].ToString();

                List <SelectListItem> ddlCity = new List <SelectListItem>();
                ddlCity      = GeneralMethods.GetDataFromSP("Select_City");
                ViewBag.City = ddlCity;

                List <SelectListItem> ddlState = new List <SelectListItem>();
                ddlState      = GeneralMethods.GetDataFromSP("Select_State");
                ViewBag.State = ddlState;

                List <SelectListItem> ddlCountry = new List <SelectListItem>();
                ddlCountry      = GeneralMethods.GetDataFromSP("Select_Country");
                ViewBag.Country = ddlCountry;

                //List<SelectListItem> ddlCustomers = new List<SelectListItem>();
                //ddlCustomers = GeneralMethods.GetDataFromSPWithDealerCode("SP_Select_Customer",dealerCode);
                //ViewBag.Customers = ddlCustomers;

                List <SelectListItem> ddlCusType = new List <SelectListItem>();
                ddlCusType      = GeneralMethods.GetDataFromSPWithDealerCode("SP_SelectCustomerType", dealerCode);
                ViewBag.CusType = ddlCusType;

                //DataTable dt = new DataTable();
                //List<CustomerVM> lst = new List<CustomerVM>();

                //SqlParameter[] sqlParam =
                //    {
                //        new SqlParameter("@DealerCode",dealerCode)
                //    };
                //dt = DataAccess.getDataTable("SP_Select_CustomerModal", sqlParam, General.GetBMSConString());

                //if (dt.Rows.Count > 0)
                //{
                //    lst = EnumerableExtension.ToList<CustomerVM>(dt);
                //}
                List <CustomerVM> lstCustommer = CustomerMethods.GetCustomerModal(dealerCode);
                ViewBag.Customer = lstCustommer;

                List <AccountVM> lstAccount = CustomerMethods.Get_AccDesc(dealerCode);
                ViewBag.Accounts = lstAccount;
            }
            else
            {
                TempData["TestAccessError"] = MessageAlert.MsgAuthorized();
                return(RedirectToAction("Error", "Definition"));
            }



            return(View());
        }
        public ActionResult Customer()
        {
            if (string.IsNullOrEmpty((string)Session["DealerCode"]))
            {
                return(RedirectToAction("Login", "Home"));
            }
            dealerCode = Session["DealerCode"].ToString();

            List <SelectListItem> ddlCity = new List <SelectListItem>();

            ddlCity      = GeneralMethods.GetDataFromSP("Select_City");
            ViewBag.City = ddlCity;

            List <SelectListItem> ddlState = new List <SelectListItem>();

            ddlState      = GeneralMethods.GetDataFromSP("Select_State");
            ViewBag.State = ddlState;

            List <SelectListItem> ddlCountry = new List <SelectListItem>();

            ddlCountry      = GeneralMethods.GetDataFromSP("Select_Country");
            ViewBag.Country = ddlCountry;

            //List<SelectListItem> ddlCustomers = new List<SelectListItem>();
            //ddlCustomers = GeneralMethods.GetDataFromSPWithDealerCode("SP_Select_Customer",dealerCode);
            //ViewBag.Customers = ddlCustomers;

            List <SelectListItem> ddlCusType = new List <SelectListItem>();

            ddlCusType      = GeneralMethods.GetDataFromSPWithDealerCode("SP_SelectCustomerType", dealerCode);
            ViewBag.CusType = ddlCusType;

            //DataTable dt = new DataTable();
            //List<CustomerVM> lst = new List<CustomerVM>();

            //SqlParameter[] sqlParam =
            //    {
            //        new SqlParameter("@DealerCode",dealerCode)
            //    };
            //dt = DataAccess.getDataTable("SP_Select_CustomerModal", sqlParam, General.GetBMSConString());

            //if (dt.Rows.Count > 0)
            //{
            //    lst = EnumerableExtension.ToList<CustomerVM>(dt);
            //}
            List <CustomerVM> lstCustommer = CustomerMethods.GetCustomerModal(dealerCode);

            ViewBag.Customer = lstCustommer;
            List <ProspectDetailVM> PreCustommer = CustomerMethods.GetPreCustomerModal(dealerCode);

            Session["PreCustomer"] = PreCustommer;
            ViewBag.PreCustomer    = PreCustommer;
            List <AccountVM> lstAccount = CustomerMethods.Get_AccDesc(dealerCode);

            ViewBag.Accounts = lstAccount;


            return(View());
        }
        public RestService()
        {
            Repository repository = new Repository();

            bookingMethods  = new BookingMethods(repository);
            carMethods      = new CarMethods(repository);
            customerMethods = new CustomerMethods(repository);
        }
示例#6
0
        public void DeleteCustomer()
        {
            Customer selectedCust = new Customer();

            selectedCust = CustList.ElementAt(SelectedIndex);
            CustomerMethods.DeleteCustomer(selectedCust);
            CustList = CustomerMethods.ListCustomers();
            NotifyPropertyChanged("");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CustomerMethods cm = new CustomerMethods();
         GridView1.DataSource = cm.ViewCustomer();
         GridView1.DataBind();
     }
 }
示例#8
0
        public CustomerDetails getCustomer(int id)
        {
            CustomerDetails cd = new CustomerDetails();
            CustomerMethods cm = new CustomerMethods();

            cd = cm.GetCustomer(id, out string errormsg);


            return(cd);
        }
示例#9
0
        public void EditCustomer()
        {
            MessageBoxResult boxResult = MessageBox.Show
                                             ("Er du sikker på at du vil redigere kunden?", "Bekræftelse", MessageBoxButton.YesNo);

            if (boxResult == MessageBoxResult.Yes)
            {
                CustomerMethods.EditCustomer(CustToEdit);
                Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive).Close();
            }
        }
示例#10
0
        public void GetCustomerLicensesTest()
        {
            var result = CustomerMethods.GetCustomerLicenses(AccessToken.AccessToken.GetCustomerLicenses,
                                                             new GetCustomerLicensesModel {
                CustomerId = 2296
            });

            if (result.Result == ResultType.Error)
            {
                Assert.Fail();
            }
        }
示例#11
0
        public void GetCustomersTest()
        {
            var result = CustomerMethods.GetCustomers(AccessToken.AccessToken.GetCustomers, new GetCustomersModel {
                Limit = 5
            });

            if (result == null || result.Result == ResultType.Error)
            {
                Assert.Fail("API error");
            }

            Assert.IsTrue(result.Customers.Count == 5);
        }
示例#12
0
        public void Post([FromBody] CustomerDetails cd)
        {
            CustomerMethods cm = new CustomerMethods();

            int Cu_Id = cm.InsertCustomer(cd, out string errormsg);

            PriceMethods pm = new PriceMethods();

            Random rand = new Random();

            // autogenerate price
            pm.InsertPrice(Cu_Id, rand.Next(501), out string errormsg1);
        }
示例#13
0
        public void CreateCust()
        {
            MessageBoxResult boxResult = MessageBox.Show("Er du sikker på at du vil gemme kunden?", "Bekræftelse", MessageBoxButton.YesNo);

            if (boxResult == MessageBoxResult.Yes)
            {
                CustomerMethods.CreateCustomer(Customer);
                MessageBox.Show(String.Format("Kunde: {0} Er nu oprettet", Customer.CompanyName));
            }
            else
            {
                MessageBox.Show("Prøv igen");
            }
        }
示例#14
0
        public JsonResult Select_Guarantor(string EnquiryId)
        {
            string data   = "";
            bool   result = false;

            data = CustomerMethods.Get_GuarantorData(EnquiryId, Session["DealerCode"].ToString());

            if (!string.IsNullOrEmpty(data))
            {
                result = true;
            }

            return(Json(new { Success = result, Response = data }, JsonRequestBehavior.AllowGet));
        }
示例#15
0
        public JsonResult Insert_Guarantor(List <GuarantorVM> objects)
        {
            bool result = false;

            string msg = "Failed to save record..";

            result = CustomerMethods.Insert_Guarantor(objects, Session["DealerCode"].ToString());

            if (result)
            {
                msg = "Successfully Added";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }
示例#16
0
        public JsonResult Insert_Customer(CustomerVM CustomerVM)
        {
            bool result = false;

            string msg = "Failed to save record..";

            result = CustomerMethods.Insert_Customer(CustomerVM, Session["DealerCode"].ToString(), ref msg);

            if (result)
            {
                msg = "Successfully Added";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }
示例#17
0
        public void AddCustomer(Customer customer)
        {
            var customerService = new CustomerMethods();

            var newCustomer = new Domain.Customer
            {
                Id        = customer.Id,
                Firstname = customer.Firstname,
                Lastname  = customer.Lastname,
                Telephone = customer.Telephone,
                Email     = customer.Email
            };

            customerService.Add(newCustomer);
        }
示例#18
0
        public void RemoveCustomer(Customer customer)
        {
            CustomerMethods customerService = new CustomerMethods();

            var removedCustomer = new Domain.Customer
            {
                Id        = customer.Id,
                Firstname = customer.Firstname,
                Lastname  = customer.Lastname,
                Telephone = customer.Telephone,
                Email     = customer.Email
            };

            customerService.Remove(removedCustomer);
        }
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("del"))
     {
         int             cid = Convert.ToInt32(e.CommandArgument);
         CustomerMethods Op  = new CustomerMethods();
         int             res = Op.Delete(cid);
         if (res > 0)
         {
             GridView1.DataSource = Op.ViewCustomer();
             GridView1.DataBind();
             Response.Write("Deactivated");
         }
     }
 }
示例#20
0
        public JsonResult Delete_Customer(string EnquiryId)
        {
            bool result = false;

            string msg = "Customer is Used , Data can't be deleted";

            result = CustomerMethods.Delete_Customer_Record(EnquiryId, Session["DealerCode"].ToString());

            if (result)
            {
                msg = "Successfully Deleted";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }
示例#21
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            CustomerMethods cm = new CustomerMethods();
            int             id = Convert.ToInt32(cid.Text);

            List <Customerbo> list = new List <Customerbo>();

            list = cm.ViewCustomerById(id);
            GridView1.DataSource = list;

            if (list.Count() == 0)

            {
                Response.Write("<script>alert('Customer Id doesnt exist')</script>");
            }

            GridView1.DataBind();
        }
示例#22
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   cn      = cname.Text;
            string   g       = ddlgender.SelectedItem.Value;
            DateTime d       = Convert.ToDateTime(dob.Text);
            long     contact = Convert.ToInt64(cno.Text);
            string   c       = city.Text;

            Customerbo      C  = new Customerbo(cn, g, d, contact, c);
            CustomerMethods CM = new CustomerMethods();

            int cid = CM.AddCustomer(C);

            if (cid > 0)
            {
                Label1.Text = "" + cid;
            }

            else
            {
                Response.Write("<script>alert('Error')</script>");
            }
        }
示例#23
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int      cusid  = Convert.ToInt32(TextBox1.Text);
            int      amount = Convert.ToInt32(TextBox2.Text);
            string   atype  = DropDownList1.SelectedItem.Value;
            DateTime dt     = DateTime.Now;

            asd.Text = "" + dt;

            Accountbo A = new Accountbo(amount, atype, cusid);

            CustomerMethods CM = new CustomerMethods();

            try { int aid = CM.AddAccount(A);
                  aid1.Text = "" + aid; }
            catch (Exception Ex)
            {
                //if (Ex.Message.Contains("ForeignKeyException"))
                //{
                Response.Write("<script>alert('The Customer Id doesn't Exists')</script>");
                //}
            }
            astatus.Text = "Active";
        }
示例#24
0
        public void AddCustomerTest()
        {
            var result = CustomerMethods.AddCustomer(AccessToken.AccessToken.CustomerAddRemoveAccessToken,
                                                     new AddCustomerModel()
            {
                Name = "Bob"
            });

            if (result.Result == ResultType.Error)
            {
                Assert.Fail();
            }

            var result2 = CustomerMethods.RemoveCustomer(AccessToken.AccessToken.CustomerAddRemoveAccessToken,
                                                         new RemoveCustomerModel()
            {
                CustomerId = result.CustomerId
            });

            if (result2.Result == ResultType.Error)
            {
                Assert.Fail();
            }
        }
        static void Main(string[] args)
        {
            //var api = new CustomerMethods();

            CarMethods.Add(new Car {
                Model = "Diablo", Brand = "Lamborgini", ManufacturingYear = 1993, RegistrationNo = "GLO892"
            });
            CarMethods.Add(new Car {
                Model = "Gallardo", Brand = "Lamborgini", ManufacturingYear = 2013, RegistrationNo = "JLO112"
            });
            CustomerMethods.Add(new Customer {
                FirstName = "Bert", LastName = "Karlsson", Email = "*****@*****.**", PhoneNumber = "6666666"
            });
            BookingMethods.Add(new Booking
            {
                CustomerId = 1,
                StartTime  = new DateTime(2018, 10, 25, 09, 00, 00),
                EndTime    = new DateTime(2019, 01, 01, 09, 00, 00),
                BookingCar = new Car {
                    Id = 1
                }
            });
            CarMethods.PickUp(1);

            //Console.WriteLine("Car rental:");

            //DateTime startDate = new DateTime(2018, 10, 25);
            //DateTime endDate = new DateTime(2019, 01, 20);

            //List<Car> availableCars = api.ListAvailableCars(startDate, endDate);

            //Console.WriteLine("Available cars (" + startDate + " to " + endDate + "):");
            //foreach (Car car in availableCars)
            //{
            //    Console.WriteLine(car.Brand + " " + car.Model);
            //}

            //var repo = new Repository();

            //    var customers = repo.DataSet<Customer>().ToList();
            //    var cars = repo.DataSet<Car>().ToList();
            //    var bookings = repo.DataSet<Booking>().ToList();


            //    repo.AddRange(new[] {
            //        new Customer
            //    {
            //        FirstName = "Pelle",
            //        LastName = "Kanin",
            //        Email = "*****@*****.**",
            //        PhoneNumber = "123123123",
            //    },
            //        new Customer
            //    {
            //        FirstName = "Gert",
            //        LastName = "Bert",
            //        Email = "*****@*****.**",
            //        PhoneNumber = "999123123",
            //    }
            //    });
            //    repo.AddRange(new[] {
            //    new Car{
            //        RegistrationNo = "ABC123",
            //        Brand = "Volvo",
            //        ManufacturingYear = 2018,
            //        Model ="V90"
            //    },
            //    new Car {
            //        RegistrationNo = "DEF456",
            //        Brand = "Volkswagen",
            //        ManufacturingYear = 2018,
            //        Model ="Passat"
            //    }
            //    }
            //    );
            //    repo.SaveChanges();

            //    repo.Add(new Booking
            //    {
            //        CustomerId = repo.DataSet<Customer>().Where(c => c.FirstName == "Pelle").Select(c => c.Id).Single(),
            //        StartTime = new DateTime(2018, 11, 01),
            //        EndTime = new DateTime(2018, 11, 03),

            //        //BookingCars = new Booking = repo.DataSet<Car>().Where(c => c.RegistrationNo == "ABC123").ToList();
            //    });
            //    repo.SaveChanges();
            //    var booking = repo.DataSet<Booking>().Where(b => b.BookingCustomer.FirstName == "Pelle").FirstOrDefault();

            //    booking.BookingCars = new[] {
            //        new BookingCar
            //        {
            //            Booking = booking,
            //            Car = repo.DataSet<Car>().Single(c => c.RegistrationNo == "ABC123")
            //        }
            //    };

            //    repo.SaveChanges();


            //customers = repo.DataSet<Customer>().ToList();
            //cars = repo.DataSet<Car>().ToList();
            //bookings = repo.DataSet<Booking>().ToList();

            //var bookingFirstName = repo.DataSet<Booking>().Where(b => b.Id == 1).Select(b => b.BookingCustomer.FirstName).Single().ToString();
            //var startDate = new DateTime(2018, 10, 25);
            //var endDate = new DateTime(2019, 01, 20);

            //CarRentalContext context = new CarRentalContext();

            //List<Booking> bookings = repo.Context.Bookings
            //    .Include(b => b.BookingCars)
            //    .ThenInclude(bc => bc.Car)
            //    .Where(b => (b.StartTime < endDate && b.EndTime > startDate)).ToList();

            //Console.WriteLine("Not available cars (" + startDate.ToString() + " to " + endDate.ToString() + "):");
            //foreach (Booking booking in bookings)
            //{
            //    foreach(BookingCar car in booking.BookingCars)
            //    {
            //        Console.WriteLine(car.Car.Brand + " " + car.Car.Model);
            //    }
            //}

            //var book = repo.DataSet<Booking>().Where(b => b.Id == 2).Single();

            //repo.Remove(book);
            //repo.SaveChanges();

            // var cust = repo.DataSet<Customer>().ToList();

            //.Where(b=>!(b.Booking.StartTime < endDate && b.Booking.EndTime > startDate))

            Console.ReadLine();
        }
示例#26
0
        public void Delete(int id)
        {
            CustomerMethods cm = new CustomerMethods();

            cm.DeleteCustomer(id, out string errormsg);
        }
示例#27
0
        public void Put([FromBody] CustomerDetails cd)
        {
            CustomerMethods cm = new CustomerMethods();

            cm.UpdateCustomer(cd, out string errormsg);
        }
示例#28
0
 public CustomerListVM()
 {
     OpenCustomerEditWindow = new MethodCommand(EditCustWindow);
     CustDelete             = new MethodCommand(DeleteCustomer);
     CustList = CustomerMethods.ListCustomers();
 }
示例#29
0
        public void GetAllProjects()
        {
            try
            {
                LogMethods.Log.Info("GetAllProjects:Info:" + "Start processing all projects");
                //create service client to call API endpoint
                using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr))
                {
                    //create SQL query statement
                    string query = "SELECT Id, Project_Number__c, Name, CloseDate, Type, OwnerId, Owner.CommunityNickname, Bidding_Type__c, Bidding_Source__c, Product_Line__c, Middle_Updated_Flag__c, "
                                   + " Bidding_Due_Date__c, Bidding_Remark__c, Sync__c, Account_Executive__r.CommunityNickname, Project_Coordinator__r.CommunityNickname, "
                                   + " (SELECT Id, Name, Billing_Company_City__c, Billing_Contact_Name__r.Account.Id, Billing_Company_Name__r.Name, Billing_Company_Name__r.Id, Billing_Company_Postal_Code__c, Billing_Company_Province__c, Billing_Company_Street__c, Billing_Contact_Name__r.FirstName, Billing_Contact_Name__r.LastName, Billing_Contact_Name__r.Id, Billing_Contact_Phone__c, Billing_Company_Country__c, Quoting_Company_City__c, Quoting_Company_Name__r.Name, Quoting_Company_Name__r.Id,  Quoting_Contact_Name__r.Account.Id, Quoting_Company_Postal_Code__c, Quoting_Company_Province__c, Quoting_Company_Street__c, Quoting_Contact_Name__r.FirstName, Quoting_Contact_Name__r.LastName, Quoting_Contact_Name__r.Id, Quoting_Contact_Phone__c, Quoting_Company_Country__c,Installing_Company_City__c, Installing_Company_Name__r.Name, Installing_Company_Name__r.Id, Installing_Contact_Name__r.Account.Id, Installing_Company_Postal_Code__c, Installing_Company_Province__c, Installing_Company_Street__c, Installing_Contact_Name__r.FirstName, Installing_Contact_Name__r.LastName, Installing_Contact_Name__r.Id, Installing_Contact_Phone__c, Installing_Company_Country__c, Billing_Account_Intersection__c, Billing_Account_Corner__c, Installing_Account_Intersection__c,Installing_Account_Corner__c,Quoting_Account_Intersection__c,Quoting_Account_Corner__c,Billing_Company_Name__r.Legal_Name__c  FROM Bill_Quote_Ships__r), "
                                   + " (SELECT Id, Number_of_Signs__c, Project_Value_Estimated__c,  Remarks__c, Issue_Date__c, Due_Date__c, LandLord__r.Name, LandLord_Contact__r.Name, LandLord_Phone_Number__c, LandLord__r.BillingStreet, LandLord__r.BillingCity, LandLord__r.BillingState, LandLord__r.BillingPostalCode FROM Sign_Permits__r),"
                                   + " (SELECT Id, Occupation_Start_Time__c, Occupation_End_Time__c, Issue_Date__c, Type_Of_Truck__c, Truck_Weight__c, Foreman_Name__r.Name, Foreman_Phone__c, Remarks__c FROM Hoisting_Permits__r),"
                                   + " (SELECT Id, Stick_Position_Radius__c, Dept_Of_Holes__c, Issue_Date__c, Due_Date__c, Remarks__c FROM StakeOut_Permits__r),"
                                   + " (SELECT Id, Name, First_Site_Contact__c, Second_Site_Contact__c, Budget__c, Provided_By__c,  Remarks__c, Due_Date__c, Rush__c, Requirement__c, Requirement_As_Other__c, Estimated_Shipping_Cost__c, Shipping_Items_Total_Value__c, Work_Order_Number__c  FROM SubContracts__r) "
                                   + " FROM Opportunity "
                                   + " WHERE Sync__c = true and Middle_Updated_Flag__c = 1 ";
                    //+ " WHERE name= '2131 Yonge Street - Exterior and Interior Signage Program'";



                    enterprise.QueryResult result;
                    queryClient.query(
                        header, //sessionheader
                        null,   //queryoptions
                        null,   //mruheader
                        null,   //packageversion
                        query, out result);

                    /* if no any record, return */
                    if (result.size == 0)
                    {
                        return;
                    }

                    //cast query results
                    IEnumerable <enterprise.Opportunity> opportunityList = result.records.Cast <enterprise.Opportunity>();

                    /*
                     * enterprise.Opportunity[] opp = new enterprise.Opportunity[result.size];
                     * int i = 0;
                     * foreach (var opportunity in opportunityList)
                     * {
                     *  enterprise.Opportunity temp = new enterprise.Opportunity();
                     *  temp.Id = opportunity.Id;
                     *  temp.Middle_Updated_Flag__c = 0;
                     *  temp.Middle_Updated_Flag__cSpecified = true;
                     *  opp[i] = temp;
                     *  i++;
                     * }
                     * enterprise.LimitInfo[] l1;
                     * enterprise.SaveResult[] s1;
                     * queryClient.update(header, null, null, null, null, null, null, null, null, null, null, null, null, opp, out l1, out s1);
                     * */

                    int size = result.size;
                    int j    = 1;
                    int k    = 0;
                    while (j <= size)
                    {
                        int limitArray = (size > 150) ? 150 : size;
                        size -= limitArray;

                        enterprise.Opportunity[] opp = new enterprise.Opportunity[limitArray];
                        int i = 0;
                        for (int m = k; m < k + limitArray; m++)
                        {
                            enterprise.Opportunity temp = new enterprise.Opportunity();
                            temp.Id = opportunityList.ElementAt(m).Id;
                            temp.Middle_Updated_Flag__c          = 0;
                            temp.Middle_Updated_Flag__cSpecified = true;
                            opp[i] = temp;
                            i++;
                        }
                        k += limitArray;
                        enterprise.LimitInfo[]  l1;
                        enterprise.SaveResult[] s1;
                        queryClient.update(header, null, null, null, null, null, null, null, null, null, null, null, null, opp, out l1, out s1);
                    }

                    //show results
                    foreach (var opportunity in opportunityList)
                    {
                        /* get project owner */
                        //string un = CommonMethods.GetUserName(opportunity.OwnerId);
                        string     un         = (opportunity.Owner.CommunityNickname == null ? "" : opportunity.Owner.CommunityNickname);
                        FsEmployee fsEmployee = new FsEmployee(un);
                        if (fsEmployee.EmployeeNumber > 0)
                        {
                            LogMethods.Log.Info("GetAllProjects:Info:" + "Processing project name:" + opportunity.Name);
                            int sales_JobMasterListID = CommonMethods.GetMISID(TableName.Sales_JobMasterList, opportunity.Id, opportunity.Id);
                            if (sales_JobMasterListID == 0)
                            {
                                int jobID = CreateNewProject(fsEmployee.EmployeeNumber);

                                /* insert data to MISSalesForceMapping */
                                if (jobID > 0)
                                {
                                    UpdateProject(jobID, opportunity.CloseDate, fsEmployee.EmployeeNumber, opportunity.Name, opportunity.Type, opportunity.Account_Executive__r, opportunity.Product_Line__c, opportunity.Project_Coordinator__r);
                                    /* update jobnumber */
                                    UpdateJobNumber(jobID, opportunity.Project_Number__c);

                                    CommonMethods.InsertToMISSalesForceMapping(TableName.Sales_JobMasterList, opportunity.Id, jobID.ToString(), opportunity.Id);
                                }
                                else
                                {
                                    LogMethods.Log.Error("GetAllProjects:Error:" + "Cannot create a new project!");
                                    continue;
                                }
                                sales_JobMasterListID = jobID;
                            }
                            else
                            {
                                UpdateProject(sales_JobMasterListID, opportunity.CloseDate, fsEmployee.EmployeeNumber, opportunity.Name, opportunity.Type, opportunity.Account_Executive__r, opportunity.Product_Line__c, opportunity.Project_Coordinator__r);
                            }

                            /* for bidding project */
                            if (opportunity.Type == SalesType.Bid)
                            {
                                /* check if the bidding record exists */
                                int biddingID = GetBiddingID(sales_JobMasterListID);
                                if (biddingID > 0)
                                {
                                    //exist
                                    UpdateBiddingProject(biddingID, sales_JobMasterListID, opportunity.Bidding_Type__c, opportunity.Bidding_Source__c, opportunity.Bidding_Due_Date__c, opportunity.Bidding_Remark__c);
                                }
                                else
                                {
                                    InsertBiddingProject(fsEmployee.EmployeeNumber);
                                    UpdateBiddingProject(SqlCommon.GetNewlyInsertedRecordID("Sales_JobMaster_BiddingJob"), Convert.ToInt32(sales_JobMasterListID), opportunity.Bidding_Type__c, opportunity.Bidding_Source__c, opportunity.Bidding_Due_Date__c, opportunity.Bidding_Remark__c);
                                }
                            }

                            /* Bill-Quote-Ship */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing account and contact");
                            CustomerMethods cm = new CustomerMethods(opportunity.Id);
                            cm.GetAllAccounts(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Bill_Quote_Ships__r);

                            /* Estimation */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing estimation");
                            EstimationMethods em = new EstimationMethods(opportunity.Id);
                            int estRevID         = CommonMethods.GetEstRevID(sales_JobMasterListID);
                            em.GetEstimation(opportunity.Id, estRevID, sales_JobMasterListID, fsEmployee.EmployeeNumber);

                            /*Drawing */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing drawing");
                            DrawingMethods dm = new DrawingMethods(opportunity.Id);
                            dm.GetAllDrawings(opportunity.Id, estRevID, sales_JobMasterListID, fsEmployee.EmployeeNumber);

                            /* Quote */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing quote");
                            QuoteMethods qm = new QuoteMethods(opportunity.Id);
                            qm.GetAllQuotes(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            /* Sign/Hoisting/Stakeout permit */
                            PermitMethods pm = new PermitMethods(opportunity.Id);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing sign permit");
                            pm.GetAllSignPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Sign_Permits__r);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing hoisting permit");
                            pm.GetAllHoistingPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.Hoisting_Permits__r);
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing stakeout permit");
                            pm.GetAllStakeOutPermits(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.StakeOut_Permits__r);

                            /* WorkOrder */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing work order");
                            WorkOrderMethods wo = new WorkOrderMethods(opportunity.Id);
                            wo.GetAllWorkOrders(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            /* Sub-Contract */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing SubContract");
                            SubContractMethods sc = new SubContractMethods(opportunity.Id);
                            sc.GetAllSubContracts(opportunity.Id, sales_JobMasterListID, fsEmployee.EmployeeNumber, opportunity.SubContracts__r);

                            /* Invoice */
                            LogMethods.Log.Debug("GetAllProjects:Debug:" + "Processing invoice");
                            InvoiceMethods im = new InvoiceMethods(opportunity.Id);
                            im.GetAllInvoices(opportunity.Id, sales_JobMasterListID, estRevID, fsEmployee.EmployeeNumber);

                            LogMethods.Log.Info("GetAllProjects:Info:" + "Done: " + opportunity.Name + "<Project Num:" + opportunity.Project_Number__c + ">");
                        }
                        else
                        {
                            LogMethods.Log.Error("GetAllProjects:Error:" + "User Name: " + un + " does not exist in database");
                        }
                    }
                    LogMethods.Log.Info("GetAllProjects:Info:" + "All projects are done");
                }
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("GetAllProjects:Error:" + e.Message);
            }
        }
示例#30
0
 public AgreementVM()
 {
     OpenAgreementWin = new MethodCommand(AgreementWinOpen);
     CustList         = CustomerMethods.ListCustomers();
 }