private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            ServiceMadeModel servMade = dgvServiceMade.SelectedItem as ServiceMadeModel;

            if (servMade != null)
            {
                if (!string.IsNullOrEmpty(datePicker.Text))
                {
                    DateTime date1   = DateTime.Parse(servMade.DateServiced);
                    string   strDate = DateTime.Now.ToShortDateString();
                    DateTime now     = DateTime.Parse(strDate);
                    if (date1 < now && user.Type > 1)
                    {
                        System.Windows.MessageBox.Show("Sorry. You can't edit previous rendered service!");
                    }
                    else
                    {
                        servMade.DateServiced = datePicker.Text;
                        ServiceForm service = new ServiceForm(this, servMade, clientModel, user);
                        service.ShowDialog();
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("Please select date.");
                }
            }
            else
            {
                System.Windows.MessageBox.Show("No record selected!");
            }
        }
Esempio n. 2
0
 public static List <string> GetListEntityNameInit()
 {
     return(new List <string>
     {
         Area.EntityName(),
         Connection.EntityName(),
         ConnectionStatus.EntityName(),
         ConnectionType.EntityName(),
         Contract.EntityName(),
         Customer.EntityName(),
         CustomerFeedback.EntityName(),
         DetailImportReceipt.EntityName(),
         Device.EntityName(),
         DeviceType.EntityName(),
         Employee.EntityName(),
         Fee.EntityName(),
         Image.EntityName(),
         ImportReceipt.EntityName(),
         Manufacturer.EntityName(),
         Payment.EntityName(),
         PaymentFee.EntityName(),
         Provider.EntityName(),
         ServiceForm.EntityName(),
         ServiceFormStatus.EntityName(),
         ServicePack.EntityName(),
         ServicePackFee.EntityName(),
         Store.EntityName(),
     });
 }
 internal static void RemoveMemory(ServiceForm objectValue)
 {
     if (DicServiceForm.ContainsKey(objectValue.Id))
     {
         DicServiceForm.Remove(objectValue.Id);
     }
 }
Esempio n. 4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceForm = await Context.ServiceForm.FirstOrDefaultAsync(m => m.ServiceFormId == id);

            if (ServiceForm == null)
            {
                return(NotFound());
            }

            var isAuthorized = await AuthorizationService.AuthorizeAsync(
                User, ServiceForm,
                ServiceFormOperations.Update);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            return(Page());
        }
Esempio n. 5
0
        protected override void Run(string serviceName, string applicationRootFolder, string configurationFile)
        {
            // Only the first container is used.

            var form = new ServiceForm(new ServiceParameters(serviceName, applicationRootFolder, configurationFile));

            form.ShowDialog();
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            ServiceForm serviceForm = db.ServiceForms.Find(id);

            serviceForm.IsDeleted    = true;
            serviceForm.DeletionDate = DateTime.Now;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        private void Service_AddButtonClicked(Object sender, EventArgs e)
        {
            try
            {
                ServiceForm Form = !Dic_Changes.Any() ? new ServiceForm(Context, UniversalCard, CardScript.CardFrame.CardHost, Guid.Empty, Convert.ToDateTime(GetControlValue(RefApplicationCard.MainInfo.RegDate)))
                    : new ServiceForm(Context, UniversalCard, CardScript.CardFrame.CardHost, Guid.Empty,
                                      Convert.ToDateTime(GetControlValue(RefApplicationCard.MainInfo.RegDate)),
                                      Dic_Changes.Select(ch => ch.DeviceNumberId.NewValue).ToList(),
                                      Dic_Changes.SelectMany(ch => String.IsNullOrEmpty(ch.Sensors.NewValue) ? new List <String>() : ch.Sensors.NewValue.Split(';').ToList()).ToList());
                switch (Form.ShowDialog())
                {
                case DialogResult.OK:
                    BaseCardProperty Row   = Table_Service[Table_Service.FocusedRowIndex];
                    Guid             RowId = Guid.NewGuid();
                    Row[RefApplicationCard.Service.Id]       = RowId;
                    Row[RefApplicationCard.Service.DeviceID] = Form.DeviceId;

                    Row[RefApplicationCard.Service.DeviceNumber]   = Form.DeviceNumber;
                    Row[RefApplicationCard.Service.DeviceNumberID] = Form.DeviceNumberId;

                    Row[RefApplicationCard.Service.AC] = Form.AC;

                    Row[RefApplicationCard.Service.Sensors] = Form.Sensors;

                    Row[RefApplicationCard.Service.Verify]    = Form.Verify;
                    Row[RefApplicationCard.Service.Repair]    = Form.Repair;
                    Row[RefApplicationCard.Service.Calibrate] = Form.Calibrate;
                    Row[RefApplicationCard.Service.Wash]      = Form.Wash;

                    Row[RefApplicationCard.Service.WarrantyServices] = Form.Warranty;

                    Row[RefApplicationCard.Service.ACList]   = Form.ACList;
                    Row[RefApplicationCard.Service.Comments] = Form.Comment;

                    Row[RefApplicationCard.Service.PackedListData] = Form.CData;
                    Row[RefApplicationCard.Service.PackedListID]   = Guid.Empty;
                    Table_Service.RefreshRow(Table_Service.FocusedRowIndex);

                    ServiceTableChange Change = (ServiceTableChange)Row;
                    Change.FileIsChanged = true;
                    Dic_Changes.Add(Change);

                    UpdateACRows(RowId, Form.ACRows.Select(i => (SKB.PaymentAndShipment.Forms.AccountCard.SaleCompleteRow)i).ToList());
                    break;

                default:
                    Table_Service.RemoveRow(CardScript.BaseObject, Table_Service.FocusedRowIndex);
                    break;
                }
            }
            catch (MyException) { Table_Service.RemoveRow(CardScript.BaseObject, Table_Service.FocusedRowIndex); }
            catch (Exception Ex) { CallError(Ex); }
        }
Esempio n. 8
0
 public override void EditSelectedItem()
 {
     if (_methoEnum == MethodologyEnum.CONSUMPTION)
     {
         ConsumptionForm frm = new ConsumptionForm(GetSelectedConsumption(), MdiParentForm);
         frm.ShowDialog();
     }
     else if (_methoEnum == MethodologyEnum.SERVICE_STATISTIC)
     {
         ServiceForm frm = new ServiceForm(GetSelectedConsumption(), MdiParentForm);
         frm.ShowDialog();
     }
 }
        public override List <BaseEntity> PopulateBusinessObjectFromReader(IDataReader dataReader)
        {
            var list = new List <BaseEntity>();

            _dicIndex = new Dictionary <string, int>();
            while (dataReader.Read())
            {
                var businessObject = new ServiceForm();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }

            return(list);
        }
        // GET: ServiceForms/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceForm serviceForm = db.ServiceForms.Find(id);

            if (serviceForm == null)
            {
                return(HttpNotFound());
            }
            return(View(serviceForm));
        }
Esempio n. 11
0
        public ActionResult InsertServiceForm(string site, string email, string mainWord, string desc, string siteType, string serviceType, string id, string phone)
        {
            try
            {
                bool isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                if (!isEmail)
                {
                    return(Json("InvalidEmail", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (HttpContext.User.Identity.IsAuthenticated)
                    {
                        string cellnum = HttpContext.User.Identity.Name;

                        User user = db.Users.Where(current => current.CellNum == cellnum && current.IsDeleted == false && current.IsActive == true).FirstOrDefault();

                        ServiceForm serviceForm = new ServiceForm();
                        serviceForm.Id              = Guid.NewGuid();
                        serviceForm.Email           = email;
                        serviceForm.FormDescription = desc;
                        serviceForm.MainWords       = mainWord;
                        serviceForm.SiteAddress     = site;
                        serviceForm.ServiceTypeId   = new Guid(serviceType);
                        serviceForm.SiteTypeId      = new Guid(siteType);
                        serviceForm.IsActive        = true;
                        serviceForm.IsDeleted       = false;
                        serviceForm.CreationDate    = DateTime.Now;
                        serviceForm.UserId          = user.Id;
                        serviceForm.ServiceId       = new Guid(id);
                        serviceForm.Phone           = phone;

                        db.ServiceForms.Add(serviceForm);
                        db.SaveChanges();
                        SendEmail(serviceForm);
                        return(Json("true", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("login", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult Edit(ServiceForm serviceForm)
 {
     if (ModelState.IsValid)
     {
         serviceForm.IsDeleted       = false;
         db.Entry(serviceForm).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ServiceGroupId = new SelectList(db.ServiceGroups, "Id", "Title", serviceForm.ServiceGroupId);
     ViewBag.ServiceTypeId  = new SelectList(db.ServiceTypes, "Id", "Title", serviceForm.ServiceTypeId);
     ViewBag.SiteTypeId     = new SelectList(db.SiteTypes, "Id", "Title", serviceForm.SiteTypeId);
     ViewBag.UserId         = new SelectList(db.Users, "Id", "Password", serviceForm.UserId);
     return(View(serviceForm));
 }
        internal static void SetMemory(ServiceForm objectValue)
        {
            string entityName = objectValue.GetName();

// chua co thi khoi tao
            if (!DicMaxKeyEntity.ContainsKey(entityName))
            {
                DicMaxKeyEntity[entityName] = 0;
            }
// co roi thi so sanh roi set max key vao dic
            if (DicMaxKeyEntity[entityName] < objectValue.Id)
            {
                DicMaxKeyEntity[entityName] = objectValue.Id;
            }
            DicServiceForm[objectValue.Id] = objectValue;
        }
Esempio n. 14
0
        private void lbtAddnew_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ForecastInfo finfo = new ForecastInfo();

            finfo.Methodology = _methoEnum.ToString();

            if (_methoEnum == MethodologyEnum.CONSUMPTION)
            {
                ConsumptionForm frm = new ConsumptionForm(finfo, MdiParentForm);
                frm.ShowDialog();
            }
            else if (_methoEnum == MethodologyEnum.SERVICE_STATISTIC)
            {
                ServiceForm frm = new ServiceForm(finfo, MdiParentForm);
                frm.ShowDialog();
            }
        }
Esempio n. 15
0
        public void Update()
        {
            QueriesTableAdapter queries = new QueriesTableAdapter();
            int highCopies = Convert.ToInt32(queries.GetNumberOfCopiesInProductSaleById(Node.Id));

            servsAdapter.FillBy(servs, Node.Id);

            if (servs.Rows.Count != 1)
            {
                throw new Exception();
            }

            var         row  = servs.Rows[0];
            ServiceForm form = new ServiceForm(Convert.ToInt32(row[2]), Convert.ToInt32(row[3]), highCopies);

            form.ShowDialog();

            int     service;
            int     copies;
            decimal cost;

            if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                service = form.Service;
                copies  = form.Copies;
                cost    = form.Cost;
            }
            else
            {
                return;
            }

            UpdateServSales(Node.Id, service, copies, cost);

            servShowAdapter.FillById(servShow, Node.Id);
            UpdateParentDeal(false);

            if (servShow.Rows.Count != 1)
            {
                throw new Exception();
            }

            row       = servShow.Rows[0];
            Node.Text = Convert.ToString(row[2]);
        }
        public ActionResult Create(ServiceForm serviceForm)
        {
            if (ModelState.IsValid)
            {
                serviceForm.IsDeleted    = false;
                serviceForm.CreationDate = DateTime.Now;
                serviceForm.Id           = Guid.NewGuid();
                db.ServiceForms.Add(serviceForm);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ServiceGroupId = new SelectList(db.ServiceGroups.Where(current => current.IsDeleted == false && current.IsActive == true), "Id", "Title", serviceForm.ServiceGroupId);
            ViewBag.ServiceTypeId  = new SelectList(db.ServiceTypes, "Id", "Title", serviceForm.ServiceTypeId);
            ViewBag.SiteTypeId     = new SelectList(db.SiteTypes, "Id", "Title", serviceForm.SiteTypeId);
            ViewBag.UserId         = new SelectList(db.Users, "Id", "CellNum", serviceForm.UserId);
            return(View(serviceForm));
        }
        // GET: ServiceForms/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceForm serviceForm = db.ServiceForms.Find(id);

            if (serviceForm == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ServiceGroupId = new SelectList(db.ServiceGroups, "Id", "Title", serviceForm.ServiceGroupId);
            ViewBag.ServiceTypeId  = new SelectList(db.ServiceTypes, "Id", "Title", serviceForm.ServiceTypeId);
            ViewBag.SiteTypeId     = new SelectList(db.SiteTypes, "Id", "Title", serviceForm.SiteTypeId);
            ViewBag.UserId         = new SelectList(db.Users, "Id", "Password", serviceForm.UserId);
            return(View(serviceForm));
        }
Esempio n. 18
0
        public void Add()
        {
            QueriesTableAdapter queries = new QueriesTableAdapter();
            int highCopies = Convert.ToInt32(queries.GetNumberOfCopiesInProductSaleById(Node.Id));

            ServiceForm form = new ServiceForm(highCopies);

            form.ShowDialog();

            int     service;
            int     copies;
            decimal cost;

            if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                service = form.Service;
                copies  = form.Copies;
                cost    = form.Cost;
            }
            else
            {
                return;
            }

            int id = InsertIntoServSales(Node.Id, service, copies, cost);

            servShowAdapter.FillById(servShow, id);
            UpdateParentDeal(true);

            if (servShow.Rows.Count != 1)
            {
                throw new Exception();
            }

            var        row     = servShow.Rows[0];
            CustomNode newNode =
                new CustomNode(text: Convert.ToString(row[2]), type: CustomNode.SERVICE, id: Convert.ToInt32(row[1]),
                               pId: Convert.ToInt32(row[0]));

            newNode.ContextMenu =
                new CustomMenu(new Controller().GetServiceMenuItems(), newNode);

            Node.Nodes.Add(newNode);
        }
Esempio n. 19
0
 public static bool ValidateUpdate(ServiceForm obj, out string errorCode, out string errorMess)
 {
     errorCode = null;
     errorMess = null;
     try
     {
         if (obj == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             return(false);
         }
         if (obj.Address == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             errorMess = "Address not allow null value";
             return(false);
         }
         if (obj.IdArea == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             errorMess = "IdArea not allow null value";
             return(false);
         }
         if (obj.IdServicePack == null)
         {
             errorCode = ErrorCodeEnum.DataInputWrong.ToString();
             errorMess = "IdServicePack not allow null value";
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logger.Write(ex.ToString());
         throw;
     }
     return(true);
 }
Esempio n. 20
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceForm = await Context.ServiceForm.FirstOrDefaultAsync(m => m.ServiceFormId == id);

            if (ServiceForm == null)
            {
                return(NotFound());
            }


            var currentUserId = UserManager.GetUserId(User);


            CHSYesWebAppUser webAppUser = await UserManager.GetUserAsync(User);

            var isAuthorized = await UserManager.IsInRoleAsync(webAppUser, Constants.ServiceFormManagersRole) ||
                               await UserManager.IsInRoleAsync(webAppUser, Constants.ServiceFormAdministratorsRole);


            //var isAuthorized = User.IsInRole(Constants.ServiceFormManagersRole) ||
            //               User.IsInRole(Constants.ServiceFormAdministratorsRole);


            if (!isAuthorized &&
                currentUserId != ServiceForm.OwnerID &&
                ServiceForm.Status != ContactStatus.Approved)
            {
                return(new ChallengeResult());
            }

            return(Page());
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(datePicker.Text))
                {
                    if (!string.IsNullOrEmpty(clientModel.ID1))
                    {
                        if (clientModel.LoyaltyID.Equals("0"))
                        {
                            if (chkAvailLoyalty.IsChecked == true)
                            {
                                clientModel.LoyaltyID = cmbLoyaltycards.SelectedValue.ToString();
                                clientModel.isLoyal   = "1";
                            }
                            else
                            {
                                clientModel.LoyaltyID = "0";
                                clientModel.isLoyal   = "0";
                            }
                        }
                        DateTime dte = DateTime.Parse(datePicker.ToString());
                        clientModel.DateServiced = dte.Year + "/" + dte.Month + "/" + dte.Day;

                        ServiceForm serviceForm = new ServiceForm(this, clientForm, clientModel, user);
                        serviceForm.ShowDialog();
                    }
                    else
                    {
                        if (checkFields())
                        {
                            ClientModel model = new ClientModel();

                            model.DateServiced = datePicker.Text;
                            model.SerialNumber = txtSerialNumber.Text;
                            model.Cod          = txtCOD.Text;
                            model.FirstName    = txtFirstName.Text;
                            model.LastName     = txtLastName.Text;
                            model.Address      = txtAddress.Text;
                            model.PhoneNumber  = txtPhoneNumber.Text;
                            model.TimeIn       = timeInPicker.Text;
                            model.TimeOut      = timeOutPicker.Text;
                            model.ServiceMode  = cmbServiceMode.SelectedValue.ToString();

                            if (chkAvailLoyalty.IsChecked == true)
                            {
                                model.LoyaltyID = cmbLoyaltycards.SelectedValue.ToString();
                                model.isLoyal   = "1";
                            }
                            else
                            {
                                model.LoyaltyID = "0";
                                model.isLoyal   = "0";
                            }

                            ServiceForm serviceForm = new ServiceForm(this, clientForm, model, user);
                            serviceForm.ShowDialog();
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Please select date.");
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
Esempio n. 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            var seriveForm = new ServiceForm();

            seriveForm.ShowDialog();
        }
        public ActionResult InsertServiceForm(string site, string email, string mainWord, string desc, string siteType, string serviceType, string id, string phone)
        {
            try
            {
                bool isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                if (!isEmail)
                {
                    return(Json("InvalidEmail", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    if (HttpContext.User.Identity.IsAuthenticated)
                    {
                        string cellnum = HttpContext.User.Identity.Name;

                        User user = db.Users.Where(current => current.CellNum == cellnum && current.IsDeleted == false && current.IsActive == true).FirstOrDefault();

                        ServiceForm serviceForm = new ServiceForm();
                        serviceForm.Id              = Guid.NewGuid();
                        serviceForm.Email           = email;
                        serviceForm.FormDescription = desc;
                        serviceForm.MainWords       = mainWord;
                        serviceForm.SiteAddress     = site;
                        serviceForm.ServiceTypeId   = new Guid(serviceType);
                        serviceForm.SiteTypeId      = new Guid(siteType);
                        serviceForm.IsActive        = true;
                        serviceForm.IsDeleted       = false;
                        serviceForm.CreationDate    = DateTime.Now;
                        serviceForm.UserId          = user.Id;
                        serviceForm.ServiceGroupId  = new Guid(id);
                        serviceForm.Phone           = phone;

                        db.ServiceForms.Add(serviceForm);
                        db.SaveChanges();
                        SendEmail(serviceForm);
                        return(Json("true", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("login", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            //catch (DbEntityValidationException e)
            //{
            //    foreach (var eve in e.EntityValidationErrors)
            //    {
            //        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
            //            eve.Entry.Entity.GetType().Name, eve.Entry.State);
            //        foreach (var ve in eve.ValidationErrors)
            //        {
            //            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
            //                ve.PropertyName, ve.ErrorMessage);
            //        }
            //    }
            //    throw;
            //}
            catch
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 24
0
        public async Task <IHttpActionResult> Post([FromBody] ServiceForm req)
        {
            try
            {
                string errorMessage = "UnknowError";
                string errorCode    = ErrorCodeEnum.UnknownError.ToString();

                #region Validate
                if (!Validate(req, out errorCode, out errorMessage))
                {
                    return(Ok(new RequestErrorCode(false, errorCode, errorMessage)));
                }
                #endregion
                // lay connectionTypeName
                string cnTypeName = "S";
                var    svPack     =
                    MemoryInfo.GetListServicePackByField(req.IdServicePack.ToString(),
                                                         ServicePack.ServicePackFields.Id);
                if (svPack != null && svPack.Count > 0 && svPack[0] != null)
                {
                    var cnType = MemoryInfo.GetListConnectionTypeByField(svPack[0].IdConnectionType.ToString(),
                                                                         ConnectionType.ConnectionTypeFields.Id);
                    if (cnType != null && cnType.Count > 0 && cnType[0] != null)
                    {
                        cnTypeName = cnType[0].Name;
                    }
                }

                var    startStringId        = cnTypeName[0];
                var    lstSvFormWithStartId = MemoryInfo.GetListServicesFormByStartId(startStringId.ToString());
                int    idSvFormWithStartId  = lstSvFormWithStartId.Count + 1;
                string serviceFormId        = startStringId.ToString();
                int    countZeroNumber      = 10 - idSvFormWithStartId.ToString().Length;
                for (int i = 0; i < countZeroNumber; i++)
                {
                    serviceFormId += "0";
                }
                serviceFormId    += idSvFormWithStartId.ToString();
                req.ServiceFormId = serviceFormId;
                #region Tạo key
                var oldKey = Memory.Memory.GetMaxKey(req.GetName());
                int newKey = oldKey + 1;
                // set key
                req.Id = newKey;
                #endregion

                #region Process
                req.CreatedAt = DateTime.Now;
                req.CreatedBy = 0;
                req.IsDeleted = 0;
                UpdateEntitySql updateEntitySql = new UpdateEntitySql();
                var             lstCommand      = new List <EntityCommand>();
                lstCommand.Add(new EntityCommand {
                    BaseEntity = new Entity.Entity(req), EntityAction = EntityAction.Insert
                });
                bool isOkDone = updateEntitySql.UpdateDefault(lstCommand);
                if (!isOkDone)
                {
                    return(Ok(new RequestErrorCode(false, errorCode, errorMessage)));
                }
                #endregion
                // update memory
                MemorySet.UpdateAndInsertEntity(req);
                var result = new RequestErrorCode(true);
                result.DataResult = req;
                return(Ok(result));
            }
            catch (Exception ex)
            {
                Logger.Write(ex.ToString());
            }
            return(BadRequest("Unknow"));
        }
Esempio n. 25
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] ServiceForm req)
        {
            try
            {
                string errorMessage = "UnknowError";
                string errorCode    = ErrorCodeEnum.UnknownError.ToString();
                #region token
                var header = Request.Headers;
                if (header.Authorization == null)
                {
                    return(StatusCode(HttpStatusCode.Unauthorized));
                }
                var      token = header.Authorization.Parameter;
                Employee employee;
                if (string.IsNullOrWhiteSpace(token) || !TokenManager.ValidateToken(token, out employee))
                {
                    return(StatusCode(HttpStatusCode.Unauthorized));
                }
                #endregion
                if (!Operator.IsAdmin(employee))
                {
                    return(Ok(new RequestErrorCode(false, ErrorCodeEnum.Error_NotHavePermision.ToString(), "Khong co quyen")));
                }

                #region Validate
                if (!ValidateUpdate(req, out errorCode, out errorMessage))
                {
                    return(Ok(new RequestErrorCode(false, errorCode, errorMessage)));
                }
                #endregion

                #region Check exist
                var obj = MemoryInfo.GetServiceForm(id);
                if (obj == null)
                {
                    return(Ok(new RequestErrorCode(false, ErrorCodeEnum.DataNotExist.ToString(), "Khong ton tai")));
                }
                #endregion
                req.Id = obj.Id;                 // gan lai id de update
                #region Process
                req.UpdatedAt = DateTime.Now;
                req.UpdatedBy = employee.Id;
                UpdateEntitySql updateEntitySql = new UpdateEntitySql();
                var             lstCommand      = new List <EntityCommand>();
                lstCommand.Add(new EntityCommand {
                    BaseEntity = new Entity.Entity(req), EntityAction = EntityAction.Update
                });
                bool isOkDone = updateEntitySql.UpdateDefault(lstCommand);
                if (!isOkDone)
                {
                    return(Ok(new RequestErrorCode(false, errorCode, errorMessage)));
                }
                #endregion
                // update memory
                MemorySet.UpdateAndInsertEntity(req);
                var result = new RequestErrorCode(true);
                result.DataResult = req;
                return(Ok(result));
            }
            catch (Exception ex)
            {
                Logger.Write(ex.ToString());
            }
            return(BadRequest("Unknow"));
        }
Esempio n. 26
0
        public JsonResult SaveServiceForm(ServiceFormModel Data)
        {
            var resultModel = new JsonResultModel <ServiceFormModel>();
            var cookie      = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            var ticket      = FormsAuthentication.Decrypt(cookie.Value);
            var gCode       = Guid.Parse(ticket.UserData);

            try
            {
                using (DataService db = new DataService())
                {
                    var serviceForm = new ServiceForm();
                    var user        = db.Context.Membership_User.FirstOrDefault(x => x.UserCode == gCode);
                    serviceForm.CompanyID  = Data.CompanyID;
                    serviceForm.CompEmp1ID = Data.CompEmp1ID;
                    serviceForm.CompEmp2ID = Data.CompEmp2ID;
                    serviceForm.EmployeeID = user.ID;

                    serviceForm.IsArıza       = Data.IsArıza;
                    serviceForm.IsBakım       = Data.IsBakım;
                    serviceForm.IsDelivering  = Data.IsDelivering;
                    serviceForm.IsDevreyeAlma = Data.IsDevreyeAlma;
                    serviceForm.IsEducate     = Data.IsEducate;
                    serviceForm.IsFirsManint  = Data.IsFirsManint;
                    serviceForm.IsFree        = Data.IsFree;
                    serviceForm.IsMeeting     = Data.IsMontage;
                    serviceForm.IsSecondMaint = Data.IsSecondMaint;
                    serviceForm.IsSupervice   = Data.IsSupervice;
                    serviceForm.IsThirdMaint  = Data.IsThirdMaint;
                    serviceForm.IsWarrantied  = Data.IsWarrantied;
                    serviceForm.IsMontage     = Data.IsMontage;
                    serviceForm.HVAC          = Data.HVAC;

                    serviceForm.JobDescription = Data.JobDescription;
                    //serviceForm.SerialNo = Data.SerialNo;
                    serviceForm.ServiceDetails = Data.ServiceDetails;
                    serviceForm.StartDate      = Data.StartDate;
                    serviceForm.EndDate        = Data.EndDate;
                    //var compAdress = db.Context.Companies.FirstOrDefault(y => y.ID == Data.CompanyID).Address;

                    //Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
                    //Microsoft.Office.Interop.Excel.Workbook sheet = excel.Workbooks.Open("/Content/ServiceFormTemplate.xlsx");
                    //Microsoft.Office.Interop.Excel.Worksheet z = excel.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;


                    //Excel.Range userRange = z.UsedRange;

                    //userRange.Replace("", compAdress);
                    //userRange.Replace("", "");
                    //sheet.SaveAs("YeniForm.pdf");
                    //return sheet;
                    //System.IO.MemoryStream memory = new System.IO.MemoryStream();
                    //byte[] bytes= System.Text.Encoding.UTF8.GetBytes(sheet);
                    //RedirectToAction("ReturnPdf", ID)
                    db.Context.ServiceForms.Add(serviceForm);
                    db.Context.SaveChanges();

                    resultModel.Status  = JsonResultType.Success;
                    resultModel.Message = "Yeni Sipariş Kaydedildi";
                }
            }
            catch (Exception)
            {
            }
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 27
0
        private void Service_DoubleClick(Object sender, EventArgs e)
        {
            try
            {
                BaseCardProperty Row   = Table_Service[Table_Service.FocusedRowIndex];
                Guid             RowId = Row[RefApplicationCard.Service.Id].ToGuid();
                ServiceForm      Form  = !Dic_Changes.Any(ch => ch.RowId != RowId) ? new ServiceForm(Context, UniversalCard, CardScript.CardFrame.CardHost, Row[RefApplicationCard.Service.DeviceID].ToGuid(), Convert.ToDateTime(GetControlValue(RefApplicationCard.MainInfo.RegDate)))
                    : new ServiceForm(Context, UniversalCard, CardScript.CardFrame.CardHost, Row[RefApplicationCard.Service.DeviceID].ToGuid(),
                                      Convert.ToDateTime(GetControlValue(RefApplicationCard.MainInfo.RegDate)),
                                      Dic_Changes.Select(ch => ch.DeviceNumberId.NewValue).ToList(),
                                      Dic_Changes.SelectMany(ch => String.IsNullOrEmpty(ch.Sensors.NewValue) ? new List <String>() : ch.Sensors.NewValue.Split(';').ToList()).ToList());

                Form.DeviceNumberId = Row[RefApplicationCard.Service.DeviceNumberID].ToGuid();
                Form.DeviceNumber   = Row[RefApplicationCard.Service.DeviceNumber] as String;

                Form.AC = (Boolean)Row[RefApplicationCard.Service.AC];

                Form.Sensors = Row[RefApplicationCard.Service.Sensors] as String;

                Form.Verify    = (Boolean)Row[RefApplicationCard.Service.Verify];
                Form.Repair    = (Boolean)Row[RefApplicationCard.Service.Repair];
                Form.Calibrate = (Boolean)Row[RefApplicationCard.Service.Calibrate];
                Form.Wash      = (Boolean)Row[RefApplicationCard.Service.Wash];

                Form.Warranty = (Boolean)Row[RefApplicationCard.Service.WarrantyServices];

                Form.ACList  = Row[RefApplicationCard.Service.ACList] as String;
                Form.Comment = Row[RefApplicationCard.Service.Comments] as String;

                String OldCData = Row[RefApplicationCard.Service.PackedListData] as String;
                Form.CData = OldCData;
                switch (Form.ShowDialog())
                {
                case DialogResult.OK:
                    Row[RefApplicationCard.Service.DeviceID] = Form.DeviceId;

                    Row[RefApplicationCard.Service.DeviceNumber]   = Form.DeviceNumber;
                    Row[RefApplicationCard.Service.DeviceNumberID] = Form.DeviceNumberId;

                    Row[RefApplicationCard.Service.AC] = Form.AC;

                    Row[RefApplicationCard.Service.Sensors] = Form.Sensors;

                    Row[RefApplicationCard.Service.Verify]    = Form.Verify;
                    Row[RefApplicationCard.Service.Repair]    = Form.Repair;
                    Row[RefApplicationCard.Service.Calibrate] = Form.Calibrate;
                    Row[RefApplicationCard.Service.Wash]      = Form.Wash;

                    Row[RefApplicationCard.Service.WarrantyServices] = Form.Warranty;

                    Row[RefApplicationCard.Service.ACList]   = Form.ACList;
                    Row[RefApplicationCard.Service.Comments] = Form.Comment;

                    Row[RefApplicationCard.Service.PackedListData] = Form.CData;
                    Table_Service.RefreshRow(Table_Service.FocusedRowIndex);
                    Grid_Service.FocusedRowHandle = -1;

                    ServiceTableChange Change = Dic_Changes.Find(RowId);
                    Change.DeviceId.NewValue = Form.DeviceId;
                    Change.FileIsChanged     = !OldCData.Equals(Form.CData);
                    Change.Warranty.NewValue = Form.Warranty;
                    Change.AC.NewValue       = Form.AC;

                    if (!OldCData.Equals(Form.CData))
                    {
                        UpdateACRows(RowId, Form.ACRows.Select(i => (SKB.PaymentAndShipment.Forms.AccountCard.SaleCompleteRow)i).ToList());
                    }
                    break;

                default:
                    Table_Service.RemoveRow(CardScript.BaseObject, Table_Service.FocusedRowIndex);
                    break;
                }
            }
            catch (Exception Ex) { CallError(Ex); }
        }
Esempio n. 28
0
        public EntityBaseSql GetMyEntity(string entityName)
        {
            #region GetMyEntity
            if (entityName.Equals(Area.EntityName()))
            {
                return(new AreaSql());
            }
            if (entityName.Equals(Connection.EntityName()))
            {
                return(new ConnectionSql());
            }
            if (entityName.Equals(ConnectionStatus.EntityName()))
            {
                return(new ConnectionStatusSql());
            }
            if (entityName.Equals(ConnectionType.EntityName()))
            {
                return(new ConnectionTypeSql());
            }
            if (entityName.Equals(Contract.EntityName()))
            {
                return(new ContractSql());
            }
            if (entityName.Equals(ContractStatus.EntityName()))
            {
                return(new ContractStatusSql());
            }
            if (entityName.Equals(Customer.EntityName()))
            {
                return(new CustomerSql());
            }
            if (entityName.Equals(CustomerFeedback.EntityName()))
            {
                return(new CustomerFeedbackSql());
            }
            if (entityName.Equals(DetailImportReceipt.EntityName()))
            {
                return(new DetailImportReceiptSql());
            }
            if (entityName.Equals(Device.EntityName()))
            {
                return(new DeviceSql());
            }
            if (entityName.Equals(DeviceType.EntityName()))
            {
                return(new DeviceTypeSql());
            }
            if (entityName.Equals(Employee.EntityName()))
            {
                return(new EmployeeSql());
            }
            if (entityName.Equals(Fee.EntityName()))
            {
                return(new FeeSql());
            }
            if (entityName.Equals(Image.EntityName()))
            {
                return(new ImageSql());
            }
            if (entityName.Equals(ImportReceipt.EntityName()))
            {
                return(new ImportReceiptSql());
            }
            if (entityName.Equals(Manufacturer.EntityName()))
            {
                return(new ManufacturerSql());
            }
            if (entityName.Equals(Payment.EntityName()))
            {
                return(new PaymentSql());
            }
            if (entityName.Equals(PaymentFee.EntityName()))
            {
                return(new PaymentFeeSql());
            }
            if (entityName.Equals(Provider.EntityName()))
            {
                return(new ProviderSql());
            }
            if (entityName.Equals(ServiceForm.EntityName()))
            {
                return(new ServiceFormSql());
            }
            if (entityName.Equals(ServiceFormStatus.EntityName()))
            {
                return(new ServiceFormStatusSql());
            }
            if (entityName.Equals(ServicePack.EntityName()))
            {
                return(new ServicePackSql());
            }
            if (entityName.Equals(ServicePackFee.EntityName()))
            {
                return(new ServicePackFeeSql());
            }
            if (entityName.Equals(Store.EntityName()))
            {
                return(new StoreSql());
            }

            #endregion

            Console.WriteLine(entityName);

            return(null);
        }
        internal void PopulateBusinessObjectFromReader(ServiceForm businessObject, IDataReader dataReader)
        {
            if (_dicIndex.Count == 0)
            {
                FillDicIndex(dataReader);
            }

            if (GetIndex(ServiceForm.ServiceFormFields.Address.ToString()) != -1)
            {
                businessObject.Address = dataReader.GetString(GetIndex(ServiceForm.ServiceFormFields.Address.ToString()));
            }

            if (GetIndex(ServiceForm.ServiceFormFields.CreatedAt.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.CreatedAt.ToString())))
                {
                    businessObject.CreatedAt = dataReader.GetDateTime(GetIndex(ServiceForm.ServiceFormFields.CreatedAt.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.CreatedBy.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.CreatedBy.ToString())))
                {
                    businessObject.CreatedBy = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.CreatedBy.ToString()));
                }
            }

            businessObject.Id = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.Id.ToString()));

            if (GetIndex(ServiceForm.ServiceFormFields.IdArea.ToString()) != -1)
            {
                businessObject.IdArea = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IdArea.ToString()));
            }

            if (GetIndex(ServiceForm.ServiceFormFields.IdCustomer.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.IdCustomer.ToString())))
                {
                    businessObject.IdCustomer = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IdCustomer.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.IdEmployee.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.IdEmployee.ToString())))
                {
                    businessObject.IdEmployee = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IdEmployee.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.IdServiceFormStatus.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.IdServiceFormStatus.ToString())))
                {
                    businessObject.IdServiceFormStatus = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IdServiceFormStatus.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.IdServicePack.ToString()) != -1)
            {
                businessObject.IdServicePack = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IdServicePack.ToString()));
            }

            if (GetIndex(ServiceForm.ServiceFormFields.IsDeleted.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.IsDeleted.ToString())))
                {
                    businessObject.IsDeleted = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.IsDeleted.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.ServiceFormId.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.ServiceFormId.ToString())))
                {
                    businessObject.ServiceFormId = dataReader.GetString(GetIndex(ServiceForm.ServiceFormFields.ServiceFormId.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.UpdatedAt.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.UpdatedAt.ToString())))
                {
                    businessObject.UpdatedAt = dataReader.GetDateTime(GetIndex(ServiceForm.ServiceFormFields.UpdatedAt.ToString()));
                }
            }

            if (GetIndex(ServiceForm.ServiceFormFields.UpdatedBy.ToString()) != -1)
            {
                if (!dataReader.IsDBNull(GetIndex(ServiceForm.ServiceFormFields.UpdatedBy.ToString())))
                {
                    businessObject.UpdatedBy = dataReader.GetInt32(GetIndex(ServiceForm.ServiceFormFields.UpdatedBy.ToString()));
                }
            }
        }
Esempio n. 30
0
        public void SendEmail(ServiceForm service)
        {
            List <EmailAddress> emails = db.EmailAddress.Where(current => current.IsDeleted == false).ToList();
            MailMessage         mail   = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");
            foreach (var item in emails)
            {
                mail.To.Add(item.Email);
            }

            DateTime today = DateTime.Today;

            mail.Body    = @" <div style='padding: 5px; direction: rtl; font-family:tahoma;'><h2>فرم درخواست زیر از سایت راش وب ارسال شده است</h2>
<table>
<tr>
<td>آدرس سایت
</td>
<td>" + service.SiteAddress + @"
</td>
</tr>

<tr>
<td>ایمیل
</td>
<td>" + service.Email + @"
</td>
</tr>

<tr>
<td>شماره تماس
</td>
<td>" + service.Phone + @"
</td>
</tr>

<tr>
<td>نوع سایت
</td>
<td>" + db.SiteTypes.Find(service.SiteTypeId).Title + @"
</td>
</tr>

<tr>
<td>نوع خدمت
</td>
<td>" + db.ServiceTypes.Find(service.ServiceTypeId).Title + @"
</td>
</tr>

<tr>
<td>کلمات کلیدی
</td>
<td>" + service.MainWords + @"
</td>
</tr>

<tr>
<td>توضیحات
</td>
<td>" + service.FormDescription + @"
</td>
</tr>
</table>
</div>
";
            mail.Subject = "فرم درخواست راش وب";

            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient("185.129.171.16");

            System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("*****@*****.**", "aW0zo1$6");
            mail.Headers.Add("Message-Id",
                             String.Concat("<", DateTime.Now.ToString("yyMMdd"), ".", DateTime.Now.ToString("HHmmss"),
                                           "*****@*****.**"));

            smtp.UseDefaultCredentials = false;

            smtp.Credentials = basicAuthenticationInfo;

            mail.Priority = MailPriority.Normal;

            smtp.Send(mail);
        }