コード例 #1
0
        public static Distributors GetDistributorByLogin(string uname, long contactNumber)
        {
            Distributors theDistributor = new Distributors();

            theDistributor = DistributorsDBManager.GetDistributorByUser(uname, contactNumber);
            return(theDistributor);
        }
コード例 #2
0
 public ViewModelDistibutorU()
 {
     currentModle  = new ModelDistibutorU();
     searchDis     = new CommandSearchDistibutor(this);
     UpdateCommend = new CommandUpdateDistibutor(this);
     distributors  = new Distributors();
 }
コード例 #3
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Distributor_Id,Name,Alamat,Kecamatan,Telpon,Faks,NPWP,Aktif")] Distributors distributor)
        {
            string dateToday       = DateTime.Now.ToString("M/dd/yyyy");
            Claim  sessionUsername = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier);
            string userName        = sessionUsername.Value;

            if (ModelState.IsValid)
            {
                var dbdistributor = db.Distributors.Create();
                dbdistributor.Distributor_Id = distributor.Distributor_Id;
                dbdistributor.Name           = distributor.Name;
                dbdistributor.Alamat         = distributor.Alamat;
                dbdistributor.Kecamatan      = distributor.Kecamatan;
                dbdistributor.Telpon         = distributor.Telpon;
                dbdistributor.Faks           = distributor.Faks;
                dbdistributor.NPWP           = distributor.NPWP;
                dbdistributor.Aktif          = distributor.Aktif;
                dbdistributor.Createdby      = userName;
                dbdistributor.Createdon      = dateToday;
                db.Distributors.Add(dbdistributor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(distributor));
        }
コード例 #4
0
        public async Task <IActionResult> PutDistributors([FromRoute] int id, [FromBody] Distributors distributors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != distributors.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DistributorsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
        public bool updateDistributor(Distributors distributor)
        {
            List <Distributors> list = new List <Distributors>();

            list = bll.selectDistributors(d => d.distributors_id == distributor.distributors_id);
            string error = "";

            if (list.Count != 1)
            {
                error += "תעודת הזהות לא קיימת במערכת";
                error += "\n";
            }
            if (error != "")
            {
                throw new Exception(error);
            }
            try
            {
                bll.UpdateDistributors(distributor);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return(true);
        }
コード例 #6
0
        public ViewModleWindowPrint(string id, DateTime date, WindowPrint view)
        {
            currentModle     = new ModelWindowPrint();
            printUser        = new CommandPrintWindow(this);
            listOfRecipients = new ObservableCollection <Recipients>();
            List <Distributors> ezerList = new List <Distributors>(currentModle.getDistributors(d => d.distributors_id == id));

            distributors             = new Distributors(ezerList[0]);
            view.FirstName.Text      = distributors.distributors_first_name;
            view.LastName.Text       = distributors.distributors_last_name;
            view.printButton.Command = printUser;


            try
            {
                listOfRecipients.Clear();
                List <Recipients> modelList = currentModle.findListOfRecipients(id, date);
                for (int i = 0; i < modelList.Count; i++)
                {
                    listOfRecipients.Add(modelList[i]);
                }
            }
            catch (Exception)
            {
            }
            view.listView.ItemsSource = listOfRecipients;
        }
コード例 #7
0
        public ActionResult Login(String uname, long contactNum)
        {
            Distributors dist = DistributorsBM.GetDistributorByLogin(uname, contactNum);

            ViewData["distributor"] = dist;
            return(View());
        }
コード例 #8
0
        public void AddDistrubutor(Distributors distrubutor)
        {
            String error = "";

            if (DateTime.Now.Year - distrubutor.distributors_date_of_birth.Year < 18)
            {
                error += "את.ה צעיר.ה מידי בכדי לעבוד כמחלק חבילות מזון";
                error += "\n";
            }
            if (distrubutor.distributors_work_days.amountOfDays() < 3)
            {
                error += "עלייך לסמן לפחות 3 ימי עבודה שבועים";
                error += "\n";
            }
            if (dalImp.addressCalculations.IsRealAdrressApi(distrubutor.distributors_address) == false)
            {
                error += "כתובת לא תקינה";
                error += "\n";
            }
            if (error == "")
            {
                try
                {
                    dalImp.AddDistrubutor(distrubutor);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
            else
            {
                throw new Exception(error);
            }
        }
コード例 #9
0
        public ActionResult RegistrationDistributor(Distributors model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new MainDbContext())
                {
                    var queryDistributor = db.Distributors.FirstOrDefault(u => u.Distributor_Id == model.Distributor_Id);

                    if (queryDistributor == null)
                    {
                        var pengecer = db.Distributors.Create();
                        pengecer.Name           = model.Name;
                        pengecer.Distributor_Id = model.Distributor_Id;
                        pengecer.Alamat         = model.Alamat;
                        pengecer.Kecamatan      = model.Kecamatan;
                        pengecer.Telpon         = model.Telpon;
                        pengecer.Faks           = model.Faks;
                        pengecer.NPWP           = model.NPWP;
                        pengecer.Aktif          = model.Aktif;
                        db.Distributors.Add(pengecer);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(RedirectToAction("RegistrationDistributor"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "One or more fields have been");
            }
            return(View());
        }
コード例 #10
0
        public void UpdateDistributor(DistributorManagementModel model)
        {
            Distributors distributor = entity.Distributors.Where(u => u.DistributorId == model.DistributorId).FirstOrDefault();

            model.DistributorCode = distributor.DistributorCode;

            distributor.DistributorName    = model.DistributorName;
            distributor.NativeCountryId    = model.NativeCountryId;
            distributor.BranchOfficeId     = model.BranchOfficeId;
            distributor.ZoneId             = model.ZoneId;
            distributor.Address            = model.Address;
            distributor.DistrictId         = model.DistrictId;
            distributor.Phone              = model.Phone;
            distributor.Email              = model.Email;
            distributor.FaxNo              = model.FaxNo;
            distributor.Web                = model.Web;
            distributor.PanNo              = model.PanNo;
            distributor.Status             = Convert.ToBoolean(model.Status);
            distributor.TimeZoneId         = model.TimeZoneId;
            distributor.UpdatedBy          = model.UpdatedBy;
            distributor.UpdatedDate        = DateTime.UtcNow;
            distributor.DistributorClassId = model.DistributorClassId;


            entity.ApplyCurrentValues(distributor.EntityKey.EntitySetName, distributor);
            entity.SaveChanges();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Distributors distributors)
        {
            if (id != distributors.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(distributors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DistributorsExists(distributors.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(distributors));
        }
コード例 #12
0
        public bool checkInfo(Distributors distributor)
        {
            string error = "";

            if (distributor.distributors_id.Length < 9)
            {
                error += "תעודת זהות קצרה מידי";
                error += "\n";
            }
            if (distributor.distributors_id.Length > 9)
            {
                error += "תעודת זהות ארוכה מידי";
                error += "\n";
            }
            if (distributor.distributors_phone_number.Length < 10)
            {
                error += "מספר הטלפון שהוזן קצר מידי";
                error += "\n";
            }
            if (distributor.distributors_email_address.Length == 0)
            {
                error += "כתובת המייל שהוזנה אינה תקינה";
                error += "\n";
            }
            else if (distributor.distributors_email_address.IndexOf('@') != distributor.distributors_email_address.IndexOf('@') || distributor.distributors_email_address.IndexOf('@') == -1)
            {
                error += "כתובת המייל שהוזנה אינה תקינה";
                error += "\n";
            }
            else if (distributor.distributors_email_address.IndexOf(".") == -1)
            {
                error += "כתובת המייל שהוזנה אינה תקינה";
                error += "\n";
            }
            if (error != "")
            {
                new WindowMessageBox(error.ToString(), "שגיאה בהזנת הנתונים", true).Show();
                //MessageBox.Show(error.ToString(), "שגיאה בהזנת הנתונים", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            else
            {
                try
                {
                    currentModle.checkInfo(distributor);
                    new WindowMessageBox("הנתונים הוזנו בהצלחה", "הנתונים הוזנו בהצלחה", false).Show();

                    //System.Windows.MessageBox.Show("הנתונים הוזנו בהצלחה", "הנתונים הוזנו בהצלחה", MessageBoxButton.OK, MessageBoxImage.None);

                    return(true);
                }
                catch (Exception exp)
                {
                    new WindowMessageBox(exp.ToString(), "שגיאה בהזנת הנתונים", true).Show();

                    //System.Windows.MessageBox.Show(exp.Message, "שגיאה בהזנת הנתונים", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            return(false);
        }
コード例 #13
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(string id)
        {
            Distributors distributor = db.Distributors.Find(id);

            db.Distributors.Remove(distributor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #14
0
        public string UpdateDistributorCodeCode(int AgentId)
        {
            Distributors agcode = entity.Distributors.Where(u => u.DistributorId == AgentId).FirstOrDefault();
            string       code   = AgentId.ToString().PadLeft(4, '0');

            agcode.DistributorCode = "AHD-" + code;
            entity.ApplyCurrentValues(agcode.EntityKey.EntitySetName, agcode);
            entity.SaveChanges();
            return(agcode.DistributorCode);
        }
コード例 #15
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "Distributor_Id,Name,Alamat,Kecamatan,Telpon,Faks,NPWP,Aktif")] Distributors distributor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(distributor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(distributor));
 }
コード例 #16
0
        public ActionResponse SaveDistributor(DistributorManagementModel modelTosave, out int _AgentId)
        {
            int DistributorId = 0;

            if (IsDistributorCodeExists(modelTosave.DistributorId, modelTosave.DistributorCode) == true)
            {
                _res.ErrNumber      = 1001;
                _res.ActionMessage  = string.Format(Resources.Message.AlreadyExist, "Distributor Code");
                _res.ResponseStatus = true;
                goto End;
            }
            else if (IsDistributorNameExists(modelTosave.DistributorId, modelTosave.DistributorName) == true)
            {
                _res.ErrNumber      = 1001;
                _res.ActionMessage  = string.Format(Resources.Message.AlreadyExist, "Distributor Name");
                _res.ResponseStatus = true;
                goto End;
            }

            Distributors datamodel = new Distributors
            {
                DistributorName    = modelTosave.DistributorName,
                NativeCountryId    = modelTosave.NativeCountryId,
                BranchOfficeId     = modelTosave.BranchOfficeId,
                ZoneId             = modelTosave.ZoneId,
                Address            = modelTosave.Address,
                DistrictId         = modelTosave.DistrictId,
                Phone              = modelTosave.Phone,
                Email              = modelTosave.Email,
                FaxNo              = modelTosave.FaxNo,
                Web                = modelTosave.Web,
                PanNo              = modelTosave.PanNo,
                Status             = Convert.ToBoolean(modelTosave.Status),
                DistributorCode    = modelTosave.DistributorCode,
                CreatedBy          = modelTosave.CreatedBy,
                CreatedDate        = DateTime.UtcNow,
                TimeZoneId         = modelTosave.TimeZoneId,
                DistributorClassId = modelTosave.DistributorClassId,
            };

            entity.AddToDistributors(datamodel);
            entity.SaveChanges();
            DistributorId  = datamodel.DistributorId;
            _res.ErrNumber = 0;
            //update agentcode here
            string AgentCode = UpdateDistributorCodeCode(DistributorId);

            _res.ActionMessage  = "Distributor Successfully Created.  Distributor Code " + AgentCode;
            _res.ResponseStatus = true;
            goto End;

End:
            _AgentId = DistributorId;
            return(_res);
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Info")] Distributors distributors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(distributors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(distributors));
        }
コード例 #18
0
 public void DeleteDistributors(Distributors distributors)
 {
     try
     {
         dalImp.DeleteDistributors(distributors);
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }
コード例 #19
0
        public async Task <IActionResult> PostDistributors([FromBody] Distributors distributors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Distributors.Add(distributors);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDistributors", new { id = distributors.Id }, distributors));
        }
コード例 #20
0
        // GET: /Distributors/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Distributors distributor = db.Distributors.Find(id);

            if (distributor == null)
            {
                return(HttpNotFound());
            }
            return(View(distributor));
        }
コード例 #21
0
 public void AddDistrubutor(Distributors distributor)
 {
     using (var ctx = new ProjectContext(connectionString))
     {
         try
         {
             ctx.Distributors.Add(distributor);
             ctx.SaveChanges();
         }
         catch (Exception)
         {
             throw new Exception("הערך כבר קיים במאגר");
         }
     }
 }
コード例 #22
0
        public double[][,] GetalllatlonRec(DateTime date)
        {
            List <WorkSchedule> workSchedules = bll.selectWorkSchedule(w => w.workSchedule_date == date);
            int count = workSchedules.Count();

            if (count == 0)
            {
                throw new Exception("לא קיים חילוק עבודה ביום זה");
            }
            if (count != 3)
            {
                throw new Exception("שגיאה במספר המחלקים");
            }

            double[][,] latlon = new double[count][, ];
            int i = 0;
            int j = 0;

            foreach (WorkSchedule workSchedule in workSchedules)
            {
                try
                {
                    Distributors      dists      = bll.selectDistributors(d => d.distributors_id == workSchedule.distributor_id)[0];
                    Address           a1         = dists.distributors_address;
                    double[]          latlon1    = bll.getLatLongFromAddress(a1);
                    List <Recipients> recipients = bll.selectRecipientsById(workSchedule.all_recipients_id);
                    latlon[i]       = new double[recipients.Count + 1, 2];
                    latlon[i][j, 0] = latlon1[0];
                    latlon[i][j, 1] = latlon1[1];
                    j++;
                    foreach (Recipients recipients1 in recipients)
                    {
                        Address  a2      = recipients1.recipients_address;
                        double[] latlon2 = bll.getLatLongFromAddress(a2);
                        latlon[i][j, 0] = latlon2[0];
                        latlon[i][j, 1] = latlon2[1];
                        j++;
                    }
                    j = 0;
                    i++;
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(latlon);
        }
コード例 #23
0
        public void DeleteDistributors(Distributors distributors)
        {
            using (var ctx = new ProjectContext(connectionString))
            {
                var itemToRemove = ctx.Distributors.Find(distributors.distributors_id); //returns a single item.

                if (itemToRemove != null)
                {
                    ctx.Distributors.Remove(itemToRemove);
                    ctx.SaveChanges();
                }
                else
                {
                    throw new Exception("הערך לא קיים");
                }
            }
        }
コード例 #24
0
        public void UpdateDistributors(Distributors distributors)
        {
            using (var ctx = new ProjectContext(connectionString))
            {
                var itemToUpdate = ctx.Distributors.Find(distributors.distributors_id); //returns a single item.

                if (itemToUpdate != null)
                {
                    ctx.Distributors.AddOrUpdate(distributors);
                    ctx.SaveChanges();
                }
                else
                {
                    throw new Exception("  הערך לא קיים במאגר");
                }
            }
        }
コード例 #25
0
        public ActionResult CreateDistributor(Distributors distributor)
        {
            try {
                if (ModelState.IsValid)
                {
                    _entities.Distributors.Add(distributor);
                    _entities.SaveChanges();
                }
                return(RedirectToAction("Index", "Home"));
            }

            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return(Redirect(Request.UrlReferrer.ToString()));
            }
        }
コード例 #26
0
        public static List <Distributors> GetAllDistributor()
        {
            List <Distributors> listOfDistributors = new List <Distributors>();

            IDbConnection conn = new MySqlConnection();

            conn.ConnectionString = connectionString;
            string     qery = "select * from distributors";
            IDbCommand cmd  = new MySqlCommand();

            cmd.CommandText = qery;
            cmd.Connection  = conn;

            MySqlDataAdapter ad = new MySqlDataAdapter(cmd as MySqlCommand);
            DataSet          ds = new DataSet();

            try
            {
                ad.Fill(ds);
                DataRowCollection rows = ds.Tables[0].Rows;


                foreach (DataRow row in rows)
                {
                    Distributors thedistributor = new Distributors();

                    thedistributor.distributorID            = int.Parse(row["distributorid"].ToString());
                    thedistributor.distributorName          = row["distributor_name"].ToString();
                    thedistributor.distributorAddress       = row["distributor_address"].ToString();
                    thedistributor.distributorContactNumber = long.Parse(row["distributor_contact_number"].ToString());

                    listOfDistributors.Add(thedistributor);
                }
            }
            catch (MySqlException e)
            {
                string message = e.Message;
            }


            return(listOfDistributors);
        }
コード例 #27
0
        public void Execute(object parameter)
        {
            var values = (Object[])parameter;

            Distributors distributor = new Distributors()
            {
                distributors_id            = values[0].ToString(),
                distributors_first_name    = values[1].ToString(),
                distributors_last_name     = values[2].ToString(),
                distributors_date_of_birth = DateTime.Parse(values[3].ToString()),
                distributors_phone_number  = values[4].ToString(),
                distributors_email_address = values[5].ToString(),
                distributors_gender        = (gender)Enum.Parse(typeof(gender), values[6].ToString()),
                distributors_address       = new Address(values[7].ToString(), values[8].ToString(), values[9].ToString()),
                distributors_work_days     = new WeekDays((bool)values[10], (bool)values[11], (bool)values[12], (bool)values[13], (bool)values[14], (bool)values[15])
            };

            _viewModel.updateDistributor(distributor);
            //throw new NotImplementedException();
        }
コード例 #28
0
        public static Distributors GetDistributorByUser(string user, double pass)
        {
            Distributors thisdistributor = new Distributors();

            IDbConnection conn = new MySqlConnection();

            conn.ConnectionString = connectionString;
            string     qery = "select * from distributors where distributor_name='" + user + "' and distributor_contact_number=" + pass + "";
            IDbCommand cmd  = new MySqlCommand();

            cmd.CommandText = qery;
            cmd.Connection  = conn;

            MySqlDataAdapter ad = new MySqlDataAdapter(cmd as MySqlCommand);
            DataSet          ds = new DataSet();

            try
            {
                ad.Fill(ds);
                DataRowCollection rows = ds.Tables[0].Rows;
                foreach (DataRow row in rows)
                {
                    //Distributors theDistributor = new Distributors();

                    thisdistributor.distributorID            = int.Parse(row["distributorid"].ToString());
                    thisdistributor.distributorName          = row["distributor_name"].ToString();
                    thisdistributor.distributorAddress       = row["distributor_address"].ToString();
                    thisdistributor.distributorContactNumber = long.Parse(row["distributor_contact_number"].ToString());
                    //thisdistributor.CustomerList = int.Parse(row["DistributorList"].ToString());
                }
            }
            catch (MySqlException e)
            {
                string message = e.Message;
            }


            return(thisdistributor);
        }
コード例 #29
0
 public static void UpdateDistributor(Distributors exitsDistributor)
 {
     DistributorsDBManager.UpdateDistributor(exitsDistributor.distributorContactNumber, exitsDistributor.distributorID);
 }
コード例 #30
0
 public ViewModelDistibutorA()
 {
     distributor1 = new Distributors();
     currentModle = new ModelDistibutorA();
     AddCommend   = new CommandAddDistibutor(this);
 }