Exemple #1
0
        private bool CheckRepeat(SupplierModel d)
        {
            object oTemp;
            string sql_Repeat = "select 1 from T_UserInfo_Supplier where (Number='" + d.Number + "' OR Name='" + d.Name + "') AND DeleteMark IS NULL AND Guid <> '" + d.Guid + "'";

            return(new Helper.SQLite.DBHelper().QuerySingleResult(sql_Repeat, out oTemp));
        }
        protected void loadData()
        {
            SupplierParser newParser = new SupplierParser();
            this.dataModel = new SupplierModel(@".\SQL2008",
                 1433, "TSQLFundamentals2008", "sa", "123456", "Production.Suppliers", newParser);
            newParser.DataModel = this.dataModel;

            try
            {
                this.dataModel.resetModel("");
            }
            catch (Exception ex)
            {
                Session["current_error"] = ex.Message;
                Response.Redirect("serverError.aspx");
            }

            /*if (this.IsPostBack == false)
                this.loadEmpIDS();*/

            if ((Request.Params.Get("suppid") != null))
            {
                this.suppID = int.Parse(Request.Params.Get("suppid").Trim());
                this.newEmpMode = false;
                if (this.IsPostBack == true)
                    return;

                this.loadSuppData();

            }
        }
        public JsonResult PutSupplierModel([FromRoute] int id, [FromBody] SupplierModel supplierModel)
        {
            if (!ModelState.IsValid)
            {
                return(new JsonResult(BadRequest(ModelState)));
            }

            if (id != supplierModel.ID)
            {
                return(new JsonResult(BadRequest()));
            }

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

            try
            {
                _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SupplierModelExists(id))
                {
                    return(new JsonResult(NotFound()));
                }
                else
                {
                    throw;
                }
            }

            return(new JsonResult(NoContent()));
        }
        public static async Task UpdateAsync_UpdatesSupplierDetails(
            [Frozen] Mock <IContactDetailsService> contactDetailsService,
            [Frozen] Mock <ISupplierSectionService> supplierSectionService,
            [Frozen] CallOffId callOffId,
            Order order,
            SupplierModel model,
            SupplierSectionController controller)
        {
            order.Supplier.Should().NotBeEquivalentTo(model);
            supplierSectionService.Setup(o => o.GetOrder(callOffId)).ReturnsAsync(order);
            supplierSectionService.Setup(o => o.SetSupplierSection(order, It.IsAny <Supplier>(), It.IsAny <Contact>())).Callback(() =>
            {
                order.Supplier = new Supplier {
                    Name = model.Name
                };
            });

            contactDetailsService
            .Setup(s => s.AddOrUpdateAddress(It.IsNotNull <Address>(), It.IsNotNull <AddressModel>()))
            .Returns(order.Supplier.Address);

            await controller.UpdateAsync(callOffId, model);

            order.Supplier.Should().BeEquivalentTo(model, o => o.Including(s => s.Name));
        }
 public async Task <IHttpActionResult> Post(SupplierModel model)
 {
     try
     {
         if (ModelState.IsValid && model != null)
         {
             var supplier = _mapper.Map <Supplier>(model);
             _repository.AddSupplier(supplier);
             if (await _repository.SaveChangesAsync())
             {
                 var newModel = _mapper.Map <SupplierModel>(supplier);
                 return(CreatedAtRoute("", "", newModel));
             }
             else
             {
                 return(Content(HttpStatusCode.Conflict, string.Format("Supplier with id {0} could not be updated", supplier.SupplierID)));
             }
         }
         else
         {
             return(Content(HttpStatusCode.BadRequest, "Incorrect input data"));
         }
     }
     catch
     {
         return(InternalServerError());
     }
 }
Exemple #6
0
        public SupplierModel GetData(string id)
        {
            SupplierModel result = null;

            var sSql = @"
                SELECT
                    SupplierID, SupplierName, Alamat, NoTelp
                FROM
                    Supplier 
                WHERE
                    SupplierID = @SupplierID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@SupplierID", id);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        dr.Read();
                        result = new SupplierModel
                        {
                            SupplierID   = dr["SupplierID"].ToString(),
                            SupplierName = dr["SupplierName"].ToString(),
                            Alamat       = dr["Alamat"].ToString(),
                            NoTelp       = dr["NoTelp"].ToString()
                        };
                    }
                }
            return(result);
        }
        public async Task <ActionResult> Add([FromBody] SupplierModel _model)
        {
            string link = URI_API.SUPPLIER_ADD;
            ResponseConsult <int> response = await PostAsJsonAsync <int>(link, _model);

            return(Ok(response));
        }
        public async Task <ActionResult> Modify(int _supplierId, [FromBody] SupplierModel _model)
        {
            string link = URI_API.SUPPLIER_MODIFY.Replace("{id}", $"{_supplierId}");
            ResponseConsult <bool> response = await PutAsJsonAsync <bool>(link, _model);

            return(Ok(response));
        }
        public void updateSupplier(SupplierModel model, int id)
        {
            using (SqlConnection connection = new SqlConnection(Constants.CONNECTION_STRING)) {
                string command_text = "UPDATE dbo.Supplier SET FirstName = @FirstName, LastName = @LastName, Company_ID = @Company_ID, Address = @Address, EMail = @EMail, Telephone = @Telephone, Comments = @Comments WHERE ID = @ID";
                using (SqlCommand command = new SqlCommand(command_text)) {
                    command.Connection = connection;
                    command.Parameters.Add("@FirstName", System.Data.SqlDbType.NVarChar, 100).Value = model.FirstName.value;
                    command.Parameters.Add("@LastName", System.Data.SqlDbType.NVarChar, 100).Value  = !string.IsNullOrEmpty(model.LastName.value) ? model.LastName.value : (object)DBNull.Value;
                    command.Parameters.Add("@Company_ID", System.Data.SqlDbType.Int).Value          = !(model.CompanyID.isNull()) ? model.CompanyID.value : (object)DBNull.Value;
                    command.Parameters.Add("@Address", System.Data.SqlDbType.NVarChar, 200).Value   = !string.IsNullOrEmpty(model.Address.value) ? model.Address.value : (object)DBNull.Value;
                    command.Parameters.Add("@EMail", System.Data.SqlDbType.VarChar, 100).Value      = !string.IsNullOrEmpty(model.EMail.value) ? model.EMail.value : (object)DBNull.Value;
                    command.Parameters.Add("@Telephone", System.Data.SqlDbType.VarChar, 100).Value  = !string.IsNullOrEmpty(model.Telephone.value) ? model.Telephone.value : (object)DBNull.Value;
                    command.Parameters.Add("@Comments", System.Data.SqlDbType.Text).Value           = !string.IsNullOrEmpty(model.Comments.value) ? model.Comments.value : (object)DBNull.Value;
                    command.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = id;

                    try {
                        connection.Open();
                        command.ExecuteNonQuery();
                        CoreApp.logger.log("Successfully supplier updated in database");
                    }
                    catch (Exception ex) { throw new Exception(ex.Message); }
                    finally {
                        try { connection.Close(); CoreApp.logger.log("Successfully connection closed"); }
                        catch (Exception ex) { throw new Exception(ex.Message); }
                    }
                }
            }
        }
Exemple #10
0
        public ActionResult Suppliers(int?pageNumber)
        {
            ViewBag.Message = "Suppliers - Add, Edit, Delete Suppliers.";

            var model = new SupplierModel()
            {
                PageNumber = (pageNumber != null ? Convert.ToInt32(pageNumber) : 1),
                PageSize   = 5
            };

            var suppliers = _supplierService.GetSuppliers();

            if (suppliers != null)
            {
                // get the suppliers to display depending on the page we are on
                model.Suppliers = suppliers.OrderBy(o => o.SupplierID)
                                  .Skip(model.PageSize * (model.PageNumber - 1))
                                  .Take(model.PageSize).ToList();

                // get a total count of the pages
                model.PageCount = suppliers.Count();
                var page = (model.PageCount / model.PageSize)
                           - (model.PageCount % model.PageSize == 0 ? 1 : 0);
            }

            return(View(model));
        }
        public static List <SupplierModel> importsupplier(List <SupplierModel> spm, out string error)
        {
            LUSSISEntities entities = new LUSSISEntities();

            error = "";
            try
            {
                foreach (SupplierModel nsm in spm)
                {
                    SupplierModel spm1 = GetSupplierBySupname(nsm.SupName, out string error1);

                    if (spm1.SupName == "")
                    {
                        CreateSupplier(nsm, out string error2);
                        spm1 = null;
                    }
                    else
                    {
                        UpdateSupplier(nsm, out string error3);
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            List <SupplierModel> sm = GetSupplierByStatus(ConSupplier.Active.ACTIVE, out string error4);

            return(sm);
        }
        public static SupplierModel GetSupplierBySupname(String name, out string error)
        {
            LUSSISEntities entities = new LUSSISEntities();

            error = "";

            supplier      sup = new supplier();
            SupplierModel sm  = new SupplierModel();

            try
            {
                sup = entities.suppliers
                      .Where(x => x.supname == name)
                      .First();
                sm = ConvertDBSupToAPISup(sup);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(sm);
        }
        public static SupplierModel ActivateSupplier(SupplierModel sm, out string error)
        {
            LUSSISEntities entities = new LUSSISEntities();
            supplier       sup      = new supplier();

            error = "";
            try
            {
                sup = entities.suppliers
                      .Where(x => x.supid == sm.SupId)
                      .First();
                sup.active = ConSupplier.Active.ACTIVE;
                entities.SaveChanges();
                sm = ConvertDBSupToAPISup(sup);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(sm);
        }
        public static SupplierModel CreateSupplier(SupplierModel sm, out string error)
        {
            LUSSISEntities entities = new LUSSISEntities();

            error = "";
            supplier sup = new supplier();

            try
            {
                sup.supname     = sm.SupName;
                sup.supemail    = sm.SupEmail;
                sup.supphone    = sm.SupPhone;
                sup.contactname = sm.ContactName;
                sup.gstregno    = sm.GstRegNo;
                sup.active      = ConSupplier.Active.ACTIVE;

                entities.suppliers.Add(sup);
                entities.SaveChanges();
                sm = ConvertDBSupToAPISup(sup);
            }
            catch (NullReferenceException)
            {
                error = ConError.Status.NOTFOUND;
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(sm);
        }
Exemple #15
0
        public async Task <IActionResult> UpdateAsync(CallOffId callOffId, SupplierModel model)
        {
            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var order = await supplierSectionService.GetOrder(callOffId);

            if (order is null)
            {
                return(NotFound());
            }

            var supplierModel = new Supplier
            {
                Id      = model.SupplierId,
                Name    = model.Name,
                Address = contactDetailsService.AddOrUpdateAddress(order.Supplier?.Address, model.Address),
            };

            var contact = contactDetailsService.AddOrUpdatePrimaryContact(
                order.SupplierContact,
                model.PrimaryContact);

            await supplierSectionService.SetSupplierSection(order, supplierModel, contact);

            return(NoContent());
        }
Exemple #16
0
        /*TrungND 21/10/16 gán thông tin cho khách sạn*/
        public List <SupplierModel> GetAllUser()
        {
            List <SupplierModel> list = new List <SupplierModel>();

            try
            {
                DataTable dt = new CDatabase().GetAllSupplier().Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    SupplierModel obj = new SupplierModel();
                    obj.ID          = Int32.Parse(dt.Rows[0]["ID"].ToString());
                    obj.Name        = dt.Rows[i]["FullName"].ToString();
                    obj.ContactName = dt.Rows[i]["UserName"].ToString();
                    obj.Mobile      = dt.Rows[i]["Mobile"].ToString().Trim();
                    obj.Address     = dt.Rows[i]["IdentityNumber"].ToString().Trim();
                    obj.Email       = dt.Rows[i]["Email"].ToString();
                    obj.Note        = dt.Rows[i]["Note"].ToString();
                    list.Add(obj);
                }
                return(list);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public static async Task UpdateAsync_InvokesAddOrUpdateAddress(
            [Frozen] Mock <IContactDetailsService> contactDetailsService,
            [Frozen] Mock <ISupplierSectionService> supplierSectionService,
            [Frozen] CallOffId callOffId,
            Order order,
            SupplierModel model,
            SupplierSectionController controller)
        {
            var originalAddress = order.Supplier.Address;

            Expression <Func <IContactDetailsService, Address> > addOrUpdateAddress = s => s.AddOrUpdateAddress(
                It.Is <Address>(a => a == originalAddress),
                It.Is <AddressModel>(a => a == model.Address));

            supplierSectionService.Setup(o => o.GetOrder(callOffId)).ReturnsAsync(order);
            supplierSectionService.Setup(o => o.SetSupplierSection(order, It.IsAny <Supplier>(), It.IsAny <Contact>())).Callback(() =>
            {
                order.Supplier.Address = originalAddress;
            });
            contactDetailsService.Setup(addOrUpdateAddress).Returns(originalAddress);

            await controller.UpdateAsync(callOffId, model);

            contactDetailsService.Verify(addOrUpdateAddress);

            order.Supplier.Address.Should().BeEquivalentTo(originalAddress);
        }
Exemple #18
0
        public List <SupplierModel> ListInforSupplier()
        {
            List <SupplierModel> list = new List <SupplierModel>();

            try
            {
                DataSet ds = new CDatabase().GetInforSupplier();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    SupplierModel obj = new SupplierModel();
                    obj.ID          = Int32.Parse(ds.Tables[0].Rows[i]["ID"].ToString());
                    obj.Name        = ds.Tables[0].Rows[i]["FullName"].ToString();
                    obj.ContactName = ds.Tables[0].Rows[i]["UserName"].ToString();
                    obj.Mobile      = ds.Tables[0].Rows[i]["Mobile"].ToString().Trim();
                    obj.Address     = ds.Tables[0].Rows[i]["IdentityNumber"].ToString().Trim();
                    obj.Email       = ds.Tables[0].Rows[i]["Email"].ToString();
                    obj.Note        = ds.Tables[0].Rows[i]["Note"].ToString();

                    if (ds.Tables[0].Rows[0]["CreateDate"] != null)
                    {
                        obj.CreateDate = DateTime.Parse(ds.Tables[0].Rows[i]["CreateDate"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["ModifyDate"] != null)
                    {
                        obj.ModifiedDate = DateTime.Parse(ds.Tables[0].Rows[i]["ModifiedDate"].ToString());
                    }
                }
                return(list);
            }
            catch (Exception)
            {
                return(list);
            }
        }
Exemple #19
0
        private void dgAccessoriesInfor_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var cellClicked = dgAccessoriesInfor.CurrentCell;
            var rowClicked  = dgAccessoriesInfor.CurrentItem as MaterialPlanModel;

            if (cellClicked == null || rowClicked == null)
            {
                return;
            }
            if (!cellClicked.Column.Equals(colSupplier))
            {
                return;
            }

            supplierClicked      = supplierAccessoriesList.FirstOrDefault(f => f.SupplierId.Equals(rowClicked.SupplierId));
            materialPlanChecking = rowClicked;

            if (string.IsNullOrEmpty(workerId) && account.MaterialDelivery)
            {
                popInputWorkerId.IsOpen = true;
                txtWorkerId.Focus();
                txtWorkerId.SelectAll();
            }
            else
            {
                LoadSupplierClicked();
            }
        }
 public static void UpdateInfo()
 {
     if (supplier != null)
     {
         supplier = SupplierDataAccess.GetSupplierById(supplier.Id.ToString());
     }
 }
        public static SupplierModel ToSupplierModel(Supplies s)
        {
            SupplierModel respVal = new SupplierModel();

            respVal.Id          = s.Id;
            respVal.Timestamp   = Settings.GetTimestamp(s.Timestamp);
            respVal.UshahidiId  = s.UshahidiId?.ToString() ?? "";
            respVal.UshahidiUrl = Settings.GetUshahidiUrl(s.UshahidiId);

            respVal.Status            = ((PostStatus)s.StatusId).GetText();
            respVal.Name              = s.Name;
            respVal.SupplierType      = ((SupplierTypes)s.SupplierTypeId).GetText();
            respVal.SupplierTypeOther = s.SupplierTypeOther;
            respVal.MeetsRegulations  = ((MeetsRegulations)s.MeetsRegulatoryRequirementsId).GetText();
            respVal.PpeTypesSupplied  = ((PpeTypes)s.PpeTypeId).GetText();
            respVal.PpeTypesOther     = s.PpeTypeOther;
            respVal.Capacity          = s.CapacityPerWeek.ToString();
            respVal.ContactDetails    = s.PhoneNumber + " " + s.Email;
            respVal.ContactName       = s.ContactName;
            respVal.Postcode          = s.Postcode;
            respVal.Website           = s.Website;
            respVal.Costs             = ((CostTypes)s.CostTypeId).GetText();
            respVal.Description       = s.Description;
            respVal.TellUsMore        = s.TellUsMore;
            respVal.Longitude         = s.Longitude.ToString();
            respVal.Latitude          = s.Latitude.ToString();

            return(respVal);
        }
Exemple #22
0
        public async Task <ActionResult <SupplierModel> > GetAsync(string orderId)
        {
            var order = await _orderRepository.GetOrderByIdAsync(orderId);

            if (order is null)
            {
                return(NotFound());
            }

            var primaryOrganisationId = User.GetPrimaryOrganisationId();

            if (primaryOrganisationId != order.OrganisationId)
            {
                return(Forbid());
            }

            var supplierModel = new SupplierModel
            {
                SupplierId     = order.SupplierId,
                Name           = order.SupplierName,
                Address        = order.SupplierAddress.ToModel(),
                PrimaryContact = order.SupplierContact.ToModel()
            };

            return(Ok(supplierModel));
        }
Exemple #23
0
        public async Task <ActionResult> UpdateAsync(string orderId, SupplierModel model)
        {
            if (model is null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var order = await _orderRepository.GetOrderByIdAsync(orderId);

            if (order is null)
            {
                return(NotFound());
            }

            var primaryOrganisationId = User.GetPrimaryOrganisationId();

            if (primaryOrganisationId != order.OrganisationId)
            {
                return(Forbid());
            }

            order.SupplierId   = model.SupplierId;
            order.SupplierName = model.Name;

            order.SupplierAddress = order.SupplierAddress.FromModel(model.Address);
            order.SupplierContact = order.SupplierContact.FromModel(model.PrimaryContact);

            var name = User.Identity.Name;

            order.SetLastUpdatedBy(User.GetUserId(), name);

            await _orderRepository.UpdateOrderAsync(order);

            return(NoContent());
        }
Exemple #24
0
        public PartialViewResult HotProducts(int id, string title)
        {
            try
            {
                SupplierModel _SUPPLIER = new SupplierModel();
                Session["SUPPLIER"]       = _SUPPLIER.GetSupplierName(id);
                Session["SUPPLIER_MODEL"] = db.SUPPLIERS.Find(id);

                ViewBag.Supplier = db.SUPPLIERS.Find(id);
                ViewBag.Header   = title;
                List <PRODUCT> _lstPRODUCT = db.PRODUCTS.Where(n => n.SUPPLIER_ID == id && n.IS_ACTIVE && n.IS_NEW).OrderByDescending(n => n.IDX).Take(8).ToList();

                if (_lstPRODUCT.Count > 7)
                {
                    return(PartialView(_lstPRODUCT));
                }
                else
                {
                    return(PartialView());
                }
            }
            catch (Exception ex)
            {
                throw ex; // 404
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string accessoriesName = txtAccessoriesName.Text.Trim().ToString();
            string supplierName    = txtSupplierName.Text.Trim().ToString();

            if (String.IsNullOrEmpty(accessoriesName) || String.IsNullOrEmpty(supplierName))
            {
                MessageBox.Show(String.Format("Acessories Name or Supplier Name is empty !"), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var upperAccessoriesSuppliersList = supplierList.Where(w => String.IsNullOrEmpty(w.ProvideAccessories) == false).ToList();
            var checkExist = upperAccessoriesSuppliersList.FirstOrDefault(f => f.ProvideAccessories.ToUpper().Equals(accessoriesName.ToUpper()) &&
                                                                          f.Name.ToUpper().Equals(supplierName.ToUpper()));

            if (checkExist != null)
            {
                MessageBox.Show(String.Format("Supplier: {0} - {1} already exist !", checkExist.Name, checkExist.ProvideAccessories), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (bwUpload.IsBusy == false)
            {
                var supplierAdd = new SupplierModel
                {
                    SupplierId         = supplierList.Max(m => m.SupplierId) + 1,
                    ProvideAccessories = accessoriesName,
                    Name = supplierName
                };

                this.Cursor      = Cursors.Wait;
                btnAdd.IsEnabled = false;
                bwUpload.RunWorkerAsync(supplierAdd);
            }
        }
Exemple #26
0
        private void edit()
        {
            SupplierModel s     = new SupplierModel(Convert.ToInt32(this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["id"].Value), this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["num"].Value.ToString(), this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells["name"].Value.ToString());
            SupplierPopup popup = new SupplierPopup(this, s);

            popup.Show();
        }
Exemple #27
0
        private void LoadFormWithData()
        {
            if (_supplierModelList == null || _supplierModelList.Count <= 0)
            {
                _isAddNewMode = true;
                return;
            }

            _supplierModel            = _supplierModelList[_currentIndex];
            txtSupplierId.Text        = Convert.ToString(_supplierModel.Id);
            txtSupplierCode.Text      = _supplierModel.SupplierCode;
            txtSupplierName.Text      = _supplierModel.SupplierName;
            txtAddress.Text           = _supplierModel.Address;
            txtOwnNumber.Text         = _supplierModel.OwnerName;
            txtContactNumber.Text     = _supplierModel.ContactNumber;
            txtEmail.Text             = _supplierModel.Email;
            txtNID.Text               = _supplierModel.NID;
            txtBankAccountNumber.Text = _supplierModel.BankAccountNumber;
            txtTIN.Text               = _supplierModel.TIN;
            txtDescription.Text       = _supplierModel.Description;
            chkIsActive.Checked       = _supplierModel.IsActive;

            dgvSupplierList.Rows[_currentIndex].Selected = true;
            dgvSupplierList.CurrentCell = dgvSupplierList.Rows[_currentIndex].Cells[0];
            _isChanged    = false;
            _isAddNewMode = false;
        }
Exemple #28
0
        /// <summary>
        /// 绑定第Index页的数据
        /// </summary>
        /// <param name="Index"></param>
        private void BindDataWithPage(int Index)
        {
            pagingCom1.PageIndex = Index;
            pagingCom1.PageSize  = 10;
            SupplierModel s = new SupplierModel();

            s.Num  = textBox1.Text;
            s.Name = textBox2.Text;
            dtData = ctrl.getFilterList(pagingCom1.PageIndex, pagingCom1.PageSize, s);
            //获取并设置总记录数
            pagingCom1.RecordCount = ctrl.getCount(s);
            dtData.Columns.Add("status");
            for (int i = 0; i < dtData.Rows.Count; i++)
            {
                if (Convert.ToBoolean(dtData.Rows[i]["isActive"]))
                {
                    dtData.Rows[i]["status"] = "激活";
                }
                else
                {
                    dtData.Rows[i]["status"] = "注销";
                }
            }

            dataGridView1.DataSource = dtData;
            pagingCom1.reSet();
        }
Exemple #29
0
        public SupplierModel GetInforSupplierByID(string id)
        {
            SupplierModel obj = new SupplierModel();

            try
            {
                DataSet ds = new CDatabase().GetInforSupplierById(id);
                if (ds.Tables.Count > 0)
                {
                    obj.ID          = Int32.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                    obj.Name        = ds.Tables[0].Rows[0]["FullName"].ToString();
                    obj.ContactName = ds.Tables[0].Rows[0]["UserName"].ToString();
                    obj.Mobile      = ds.Tables[0].Rows[0]["Mobile"].ToString().Trim();
                    obj.Address     = ds.Tables[0].Rows[0]["IdentityNumber"].ToString().Trim();
                    obj.Email       = ds.Tables[0].Rows[0]["Email"].ToString();
                    obj.Note        = ds.Tables[0].Rows[0]["Note"].ToString();

                    if (ds.Tables[0].Rows[0]["CreateDate"] != null)
                    {
                        obj.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["ModifyDate"] != null)
                    {
                        obj.ModifiedDate = DateTime.Parse(ds.Tables[0].Rows[0]["ModifiedDate"].ToString());
                    }
                }
                return(obj);
            }
            catch (Exception ex)
            {
                return(obj);
            }
        }
Exemple #30
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox2.Text == "")
     {
         MessageBox.Show("字段必填!");
     }
     else
     {
         SupplierModel s;
         if (olds != null && olds.Id > 0)
         {
             s = new SupplierModel(olds.Id, textBox1.Text, textBox2.Text);
         }
         else
         {
             s = new SupplierModel(textBox1.Text, textBox2.Text);
         }
         MessageModel msg = ctrl.add(s);
         if (msg.Code == 0)
         {
             parentForm.loadData();
             this.Close();
         }
         else
         {
             MessageBox.Show(msg.Msg);
         }
     }
 }
Exemple #31
0
        /// <summary>
        /// POST /api/suppliers
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public HttpResponseMessage Post(SupplierModel model)
        {
            var context = this.DbContext;

            if (!this.User.CanCreate <Supplier>())
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }

            // transform the SupplierModel to Supplier
            var entity = model.TransformTo <Supplier>();

            // add the entity
            context.Suppliers.Add(entity);

            // persist changes to the database
            context.SaveChanges();

            // fire the web event
            new SupplierCreatedEvent(entity).Raise();

            // create response
            var    response = Request.CreateResponse <SupplierModel>(HttpStatusCode.Created, selector(entity));
            string uri      = Url.Link("Api", new { id = entity.Id });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        SupplierModel model = new SupplierModel();
        Supplier c = CreateSupplier();

        lblResult.Text = model.InsertSupplier(c);
        Response.Redirect("~/Pages/Management/ManageWebsite.aspx", false);
    }
        protected void _initModel()
        {
            Settings  setting = new Settings();

            SupplierParser newParser = new SupplierParser();

            dataModel = new SupplierModel(
                                this.gvSuppliers,
                                setting.DB_HOST,
                                setting.DB_PORT,
                                setting.DB_NAME,
                                setting.DB_USER,
                                setting.DB_PASS,
                                "Production.Suppliers",
                                newParser);
               //dataModel = new SupplierModel(this.gvSuppliers, ".\\SQL2008", setting.DB_PORT, setting.DB_NAME, setting.DB_USER, setting.DB_PASS, "Production.Suppliers", newParser);

            newParser.DataModel = dataModel;

            dataModel.resetControl();
        }
        public SupplierViewModel(SupplierModel model)
        {
            this.Id = model.Id;                                   //主键
            this.No = model.No;                                   //供应商编号
            this.Type = model.Type;                               //供应商类别

            this.ChName = model.ChName;                           //中文名称
            this.EnName = model.EnName;                           //英文名称
            this.ShortName = model.ShortName;                     //简称

            this.Countryid = model.Countryid.ToString();          //国家
            this.Address = model.Address;                         //地址
            this.Phone = model.Phone;                             //电话

            this.Email = model.Email;                             //邮箱
            this.Linkman = model.Linkman;                         //联系人
            this.Remark = model.Remark;                           //备注

            this.ApprovalStatus = model.ApprovalStatus;           //审批状态
            this.OpeningBank = model.OpeningBank;                 //开户行
            this.BankAccount = model.BankAccount;                 //开户行账号
        }
 private void PopulateSuppliers()
 {
     suppliers = supplierService.GetSupplierList().Select(s => new SupplierModel() { Id = s.Id, Name = s.Name, Email =
         s.Email }).ToList();
     var defaultSupplier = new SupplierModel() { Name = "Empty" };
     suppliers.Add(defaultSupplier);
     ViewData["Suppliers"] = suppliers;
     ViewData["defaultSupplier"] = defaultSupplier;
 }
        public string Add(SupplierViewModel model)
        {
#if DEBUG
            SysConfig.CurrentUser = UserModel.SingleOrDefault("3");
#endif
            if (ModelState.IsValid)
            {
                SupplierModel supplier = new SupplierModel();
                supplier.No = CommonMethod.GetLatestSerialNo(SysConfig.SerialNo.SupplierNo);        //供应商编号
                supplier.Type = model.Type;                                                         //供应商类别

                supplier.ChName = model.ChName;                                                     //中文名称
                supplier.EnName = model.EnName;                                                     //英文名称
                supplier.ShortName = model.ShortName;                                               //简称

                supplier.Countryid = model.Countryid.ToInt();                                       //国家
                supplier.Address = model.Address;                                                   //地址
                supplier.Phone = model.Phone;                                                       //电话

                supplier.Email = model.Email;                                                       //邮箱
                supplier.Linkman = model.Linkman;                                                   //联系人
                supplier.Remark = model.Remark;                                                     //备注

                supplier.BelongsMan = CommonMethod.GetBelongsMan(                                   //业务员
                    SysConfig.CurrentUser.Departmentid.ToString());
                supplier.BelongsDepartment = CommonMethod.GetBelongsDepartment(                     //业务部门
                    SysConfig.CurrentUser.Departmentid.ToString());

                ApprovalRuleModel rule = ApprovalRuleModel.FirstOrDefault(@"where Del_Flag = 0 and Doc_Type = 2 
                                                                                and DepartmentID = @0", supplier.BelongsDepartment);
                //如果没有审批规则 则直接生效
                if (rule == null)
                {
                    supplier.ApprovalStatus = "4";                                                  //审批状态  4:已生效
                }
                //如果有审批规则 则待提交
                else
                {
                    supplier.ApprovalStatus = "1";                                                  //审批状态  1:待提交
                }

                supplier.OpeningBank = model.OpeningBank;                                           //开户行
                supplier.BankAccount = model.BankAccount;                                           //开户行账号
                supplier.DelFlag = 0;                                                               //有效状态

                supplier.CreateMan = SysConfig.CurrentUser.Id;                                      //制单人
                supplier.CreateTime = DateTime.Now;                                                 //制单时间

                int result = supplier.Insert().ToInt();

                if (result > 0)
                {
                    //更新供应商最大序列号
                    CommonMethod.UpdateSerialNo(SysConfig.SerialNo.SupplierNo);

                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Supplier");
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_SerialNo");

                    return "1";
                }
            }
            return "0";
        }
 public EditSupplier(SupplierModel DataModel)
 {
     InitializeComponent();
     dataModel = DataModel;
 }
        public Supplier getSupplier(SupplierModel model)
        {
            var supplier = new Supplier();

            if (model != null)
            {
                supplier.Address = model.Address;
                supplier.City = model.City;
                supplier.Country = model.Country;
                supplier.Phone = model.Phone;
                supplier.PostalCode = model.PostalCode;
                supplier.Products = getProduct(model.Products);
                supplier.Region = model.Region;
                supplier.SupplierId = model.SupplierId;
                supplier.SupplierName = model.SupplierName;
                supplier.SupplierTitle = model.SupplierTitle;
            }

            return supplier;
        }
        public List<SupplierModel> getSupplier(IEnumerable<Supplier> data)
        {
            var list = new List<SupplierModel>();
            if (data.Count() > 0)
            {
                foreach (var model in data)
                {
                    var supplier = new SupplierModel();

                    if (model != null)
                    {
                        supplier.Address = model.Address;
                        supplier.City = model.City;
                        supplier.Country = model.Country;
                        supplier.Phone = model.Phone;
                        supplier.PostalCode = model.PostalCode;
                        supplier.Products = getProduct(model.Products);
                        supplier.Region = model.Region;
                        supplier.SupplierId = model.SupplierId;
                        supplier.SupplierName = model.SupplierName;
                        supplier.SupplierTitle = model.SupplierTitle;
                    }
                    list.Add(supplier);
                }
            }
            return list;
        }