Exemplo n.º 1
0
        public void AddCashier(CashierModel cashier)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;
            // создаем новый элемент user
            XmlElement userElem = xDoc.CreateElement("Cashier");
            // создаем атрибут name
            XmlElement nameElem = xDoc.CreateElement("FirstName");
            // создаем элементы surname и pasport
            XmlElement surnameElem = xDoc.CreateElement("LastName");
            XmlElement pasportElem = xDoc.CreateElement("Pasport");
            XmlElement onWorkElem  = xDoc.CreateElement("OnWork");

            // создаем текстовые значения для элементов и атрибута
            XmlText nameText    = xDoc.CreateTextNode(cashier.Name);
            XmlText surnameText = xDoc.CreateTextNode(cashier.Surname);
            XmlText pasportText = xDoc.CreateTextNode(cashier.Pasport);
            XmlText onWorkText  = xDoc.CreateTextNode(cashier.OnWork);

            //добавляем узлы
            nameElem.AppendChild(nameText);
            surnameElem.AppendChild(surnameText);
            pasportElem.AppendChild(pasportText);
            onWorkElem.AppendChild(onWorkText);

            userElem.AppendChild(nameElem);
            userElem.AppendChild(surnameElem);
            userElem.AppendChild(pasportElem);
            userElem.AppendChild(onWorkElem);

            xRoot.AppendChild(userElem);
            xDoc.Save(XMLaddress);
        }
        public void ToMakeNoteInHistory(string name, string surname, string passport, string currencyForSale,
                                        string valueForSale, string currencyForBuy, string valueForBuy)
        {
            DateTime time = new DateTime();

            time = DateTime.Now;

            CashierModel workingCashier = cashiersRep.GetWorkingCashier();

            Excel.Application xlApp = new Excel.Application();
            //xlApp.Visible = true;
            Excel.Workbook xlWb = xlApp.Workbooks.Open(historyAddress,
                                                       Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                       Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                       Type.Missing, Type.Missing);

            Excel.Worksheet xlSht = xlWb.Sheets[1];
            int             num   = xlSht.Cells.Find("*", Type.Missing, Excel.XlFindLookIn.xlValues,
                                                     Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlPrevious,
                                                     false, false, Type.Missing).Row;

            xlSht.Cells[num + 1, "A"] = num;
            xlSht.Cells[num + 1, "B"] = workingCashier.Name + " " + workingCashier.Surname;
            xlSht.Cells[num + 1, "C"] = name + " " + surname;
            xlSht.Cells[num + 1, "D"] = passport;
            xlSht.Cells[num + 1, "E"] = valueForSale + " " + currencyForSale;
            xlSht.Cells[num + 1, "F"] = valueForBuy + " " + currencyForBuy;
            xlSht.Cells[num + 1, "G"] = time;

            xlWb.Save();
            xlWb.Close(true, Type.Missing, Type.Missing); //закрыть и сохранить книгу
            xlApp.Quit();
        }
Exemplo n.º 3
0
        public void ToDelete(string nameSurnameCashier)
        {
            string       name    = GetCashierName(nameSurnameCashier);
            string       surname = GetCashierSurname(nameSurnameCashier);
            CashierModel cashier = new CashierModel(name, surname, null, null);

            cashiersRep.DeleteCashier(cashier);
        }
        public void SetCashierAsCurrentWorker(string nameSurnameCashier)
        {
            string cashierName = GetCashierName(nameSurnameCashier);
            string cashierSurname = GetCashierSurname(nameSurnameCashier);

            CashierModel cashier = new CashierModel(cashierName, cashierSurname, string.Empty, string.Empty);

            cashiersRep.SetCashierWorking(cashier);
        }
Exemplo n.º 5
0
        public void setConfig(CashierModel cashier)
        {
            if (!Directory.Exists(path))         //不存在path文件夹
            {
                Directory.CreateDirectory(path); //新建文件夹
            }
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(CashierModel));
            Stream        stream        = new FileStream(path + fname, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);

            xmlSerializer.Serialize(stream, cashier);
            stream.Close();
        }
Exemplo n.º 6
0
        public CashierModel getConfig()
        {
            CashierModel cashier = new CashierModel();

            if (File.Exists(path + fname))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(CashierModel));
                Stream        stream        = new FileStream(path + fname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                cashier = (CashierModel)xmlSerializer.Deserialize(stream);
            }

            return(cashier);
        }
Exemplo n.º 7
0
        private void btnSetCashier(object sender, EventArgs e)
        {
            CashierModel workingCashier = presenter.GetWorkingCashier();

            foreach (RadioButton rbtn in rbtnList)
            {
                if (rbtn.Checked)
                {
                    presenter.SetCashier(rbtn.Text, workingCashier);
                }
            }
            txtBoxMassageView.Text = "Кассир установлен как работающий";
        }
Exemplo n.º 8
0
        public CashierModel GetWorkingCashier()
        {
            CashierModel workingCashier = new CashierModel(null, null, null, null);

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;

            bool needToExit = false;

            foreach (XmlElement xnode in xRoot)
            {
                foreach (XmlNode childnode in xnode.ChildNodes)
                {
                    if (childnode.Name == "OnWork")
                    {
                        if (childnode.InnerText == "Yes")
                        {
                            foreach (XmlNode innerNode in xnode.ChildNodes)
                            {
                                if (innerNode.Name == "FirstName")
                                {
                                    workingCashier.Name = innerNode.InnerText;
                                }

                                if (innerNode.Name == "LastName")
                                {
                                    workingCashier.Surname = innerNode.InnerText;
                                }
                                if (innerNode.Name == "Pasport")
                                {
                                    workingCashier.Pasport = innerNode.InnerText;
                                    needToExit             = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (needToExit)
                    {
                        break;
                    }
                }
                if (needToExit)
                {
                    break;
                }
            }
            return(workingCashier);
        }
Exemplo n.º 9
0
        public void SetCashierWorking(CashierModel cashier)
        {
            CashierModel workingCashier = cashier;
            string       name = String.Empty, surname = String.Empty;
            string       pasport = String.Empty, onWork = String.Empty;

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;

            bool isNameCoincidence    = false;
            bool isSurnameCoincidence = false;
            bool needExit             = false;

            foreach (XmlElement xnode in xRoot)
            {
                foreach (XmlNode childnode in xnode.ChildNodes)
                {
                    if (childnode.Name == "FirstName")
                    {
                        if (childnode.InnerText == workingCashier.Name)
                        {
                            isNameCoincidence = true;
                        }
                    }
                    if (childnode.Name == "LastName")
                    {
                        if (childnode.InnerText == workingCashier.Surname)
                        {
                            isSurnameCoincidence = true;
                        }
                    }
                    if (childnode.Name == "OnWork")
                    {
                        if (isNameCoincidence && isSurnameCoincidence)
                        {
                            childnode.InnerText = "Yes";
                            needExit            = true;
                        }
                    }
                }
                if (needExit)
                {
                    break;
                }
            }
            xDoc.Save(XMLaddress);
        }
        public bool Update(CashierModel c)
        {
            _methodName = "Update(CashierModel c) fail...";

            try
            {
                if (c == null || c.CashierID <= 0)
                {
                    return(false);
                }

                var entity = _context.Cashiers.Where(cas => cas.CashierID == c.CashierID).FirstOrDefault();

                if (entity != null)
                {
                    entity.FullName        = c.FullName;
                    entity.NumberOfOffices = c.NumberOfOffices;
                }

                _context.Entry(entity).State = EntityState.Modified;

                if (Save())
                {
                    return(true);
                }

                DebugWrite(_methodName, String.Empty);
                return(false);
            }
            catch (NullReferenceException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (ArgumentException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
        }
Exemplo n.º 11
0
        public void DeleteCashier(CashierModel cashier)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;

            bool isNameCoincidence    = false;
            bool isSurnameCoincidence = false;
            bool needExit             = false;

            foreach (XmlElement xnode in xRoot)
            {
                foreach (XmlNode childnode in xnode.ChildNodes)
                {
                    if (childnode.Name == "FirstName")
                    {
                        if (childnode.InnerText == cashier.Name)
                        {
                            isNameCoincidence = true;
                        }
                    }
                    if (childnode.Name == "LastName")
                    {
                        if (childnode.InnerText == cashier.Surname)
                        {
                            isSurnameCoincidence = true;
                        }
                    }
                    if (childnode.Name == "OnWork")
                    {
                        if (isNameCoincidence && isSurnameCoincidence)
                        {
                            xnode.RemoveAll();
                            needExit = true;
                        }
                    }
                }
                if (needExit)
                {
                    break;
                }
            }
            xDoc.Save(XMLaddress);
        }
Exemplo n.º 12
0
        public List <CashierModel> GetCashiers()
        {
            List <CashierModel> cashiers = new List <CashierModel>();
            string name = String.Empty, surname = String.Empty;
            string pasport = String.Empty, onWork = String.Empty;

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;

            foreach (XmlElement xnode in xRoot)
            {
                foreach (XmlNode childnode in xnode.ChildNodes)
                {
                    if (childnode.Name == "FirstName")
                    {
                        name = childnode.InnerText;
                    }

                    if (childnode.Name == "LastName")
                    {
                        surname = childnode.InnerText;
                    }

                    if (childnode.Name == "Pasport")
                    {
                        pasport = childnode.InnerText;
                    }

                    if (childnode.Name == "OnWork")
                    {
                        onWork = childnode.InnerText;
                    }
                }
                CashierModel cashier = new CashierModel(name, surname, pasport, onWork);
                cashiers.Add(cashier);
                name    = string.Empty;
                surname = string.Empty;
                pasport = string.Empty;
                onWork  = string.Empty;
            }
            return(cashiers);
        }
        public bool Add(CashierModel entity)
        {
            _methodName = "Add(CashierModel entity) fail...";

            try
            {
                if (entity == null)
                {
                    return(false);
                }

                _context.Cashiers.Add(new Cashier
                {
                    NumberOfOffices = entity.NumberOfOffices,
                    FullName        = entity.FullName
                });

                if (Save())
                {
                    return(true);
                }

                DebugWrite(_methodName, String.Empty);
                return(false);
            }
            catch (NullReferenceException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (ArgumentException ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                DebugWrite(_methodName, ex.Message);
                return(false);
            }
        }
Exemplo n.º 14
0
        public List <CashierModel> GetCashier(string username)
        {
            List <CashierModel> items = new List <CashierModel>();

            try
            {
                OpenConnection();

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = _connnection;
                    cmd.CommandText = string.Format("EXEC GetCashier '{0}'", username);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int i    = 0;
                            var item = new CashierModel();

                            item.Id           = reader.GetInt32(i++);
                            item.Cashier_Name = reader.GetString(i++);
                            item.Cashier_Rank = reader.GetString(i++);
                            item.Email        = reader.GetString(i++);

                            items.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                CloseConnection();
            }

            return(items);
        }
Exemplo n.º 15
0
        public void ToMackCashierUnwork(CashierModel cashier)
        {
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(XMLaddress);
            XmlElement xRoot = xDoc.DocumentElement;

            bool needToExit = false;

            foreach (XmlElement xnode in xRoot)
            {
                foreach (XmlNode childnode in xnode.ChildNodes)
                {
                    if (childnode.Name == "Pasport")
                    {
                        if (childnode.InnerText == cashier.Pasport)
                        {
                            foreach (XmlNode innerNode in xnode.ChildNodes)
                            {
                                if (innerNode.Name == "OnWork")
                                {
                                    innerNode.InnerText = "No";
                                    needToExit          = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (needToExit)
                {
                    break;
                }
            }
            xDoc.Save(XMLaddress);
        }
        public void ToMakeCheck(string name, string surname, string passport, string currencyForSale,
                                string valueForSale, string currencyForBuy, string valueForBuy)
        {
            CashierModel workingCashier = cashiersRep.GetWorkingCashier();

            string[] check = new string[9]; //System.IO.File.ReadAllLines(checkAddress, Encoding.Default);
            check[0] = "        Чек";
            check[1] = "Обменный пункт №7";
            check[2] = "ул.Курчатова,3";
            check[3] = "Клиент: " + surname + " " + name;
            check[4] = "Куплено: " + valueForBuy + " " + currencyForBuy;
            check[5] = "Продано: " + valueForSale + " " + currencyForSale;
            check[6] = "Кассир: " + workingCashier.Surname + " " + workingCashier.Name;
            check[7] = "    " + DateTime.Now;
            check[8] = "    Хорошего дня!";

            using (StreamWriter sw = new StreamWriter(checkAddress, false, System.Text.Encoding.Default))
            {
                foreach (string str in check)
                {
                    sw.WriteLine(str);
                }
            }
        }
        public ActionResult Index()
        {
            var areaListResult = AreaService.ListAllByBranch <LanguageAreaDto>(SmsCache.UserContext.CurrentBranchId);

            if (!areaListResult.Success || areaListResult.Data == null)
            {
                return(ErrorPage(areaListResult.Errors));
            }

            var productListResult = ProductService.ListAllByBranch <SearchProductDto>(SmsCache.UserContext.CurrentBranchId);

            if (!productListResult.Success || productListResult.Data == null)
            {
                return(ErrorPage(productListResult.Errors));
            }

            var cashierModel = new CashierModel
            {
                ListArea    = areaListResult.Data,
                ListProduct = productListResult.Data,
            };

            return(View(cashierModel));
        }
Exemplo n.º 18
0
        public CashierModel GetWorkingCashier()
        {
            CashierModel workingCashier = cashierService.ToGetWorkingCashier();

            return(workingCashier);
        }
 public void ToFinishWork()
 {
     CashierModel cashier = cashiersRep.GetWorkingCashier();
     cashier.OnWork = "No";
     cashiersRep.ToMackCashierUnwork(cashier);
 }
Exemplo n.º 20
0
        public CashierResponse GetDetail(long medicalid)
        {
            List <CashierModel> lists = new List <CashierModel>();
            dynamic             data;
            CashierResponse     cashierResponse = new CashierResponse();

            //long formmedicalid = _unitOfWork.FormMedicalRepository.Get(a => a.PatientID == patienid).Select(x => x.ID).FirstOrDefault();
            long examineid = _unitOfWork.FormExamineRepository.Get(x => x.FormMedicalID == medicalid).Select(x => x.ID).FirstOrDefault();

            if (medicalid != 0)
            {
                var formexeminelab      = _unitOfWork.FormExamineLabRepository.Query(x => x.FormMedicalID == medicalid);
                var FormExamineMedicine = _unitOfWork.FormExamineMedicineRepository.Get(x => x.FormExamineID == examineid);
                var FormExamineservice  = _unitOfWork.FormExamineServiceRepository.Get(x => x.FormExamineID == examineid);
                if (formexeminelab != null)
                {
                    foreach (var item in formexeminelab)
                    {
                        var labdata = new CashierModel
                        {
                            ItemName = item.LabItem.Name,
                            Price    = Convert.ToInt32(item.LabItem.Price)
                        };

                        lists.Add(labdata);
                    }
                }

                if (FormExamineservice != null)
                {
                    foreach (var item in FormExamineservice)
                    {
                        var labdata = new CashierModel
                        {
                            ItemName = item.Service.Name,
                            Price    = Convert.ToInt32(item.Service.Price)
                        };

                        lists.Add(labdata);
                    }
                }

                if (FormExamineMedicine != null)
                {
                    foreach (var item in FormExamineMedicine)
                    {
                        var labdata = new CashierModel
                        {
                            ItemName = item.Product.Name,
                            Price    = Convert.ToInt32(item.Product.RetailPrice)
                        };

                        lists.Add(labdata);
                    }
                }


                data = lists.ToList();
                if (data != null)
                {
                    cashierResponse = new CashierResponse
                    {
                        Data = data
                    };
                }
                else
                {
                    cashierResponse = new CashierResponse();
                }
            }

            return(cashierResponse);
        }
 public bool Remove(CashierModel entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
        public void CreateCashier(string name, string surname, string passport)
        {
            CashierModel cashier = new CashierModel(name, surname, passport, "No");

            cashiersRep.AddCashier(cashier);
        }
 public void setConfig(CashierModel cashier)
 {
     cd.setConfig(cashier);
 }
Exemplo n.º 24
0
 public void SetCashier(string nameSurnameCashier, CashierModel workingCashier)
 {
     cashierService.SetCashierAsCurrentWorker(nameSurnameCashier, workingCashier);
 }