Пример #1
0
        public void AddMaterial_AddEmptyFile_NotNull()
        {
            Material material = new Material {
                Name = "newmaterial", Category = "Other"
            };
            IFormFile file = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("new")), 0, 0, "Data", "text1.txt");

            var result = _materialService.AddMaterial(material, file);

            Assert.NotNull(result);
        }
Пример #2
0
        public async Task <bool> AddMaterial()
        {
            var path = @"/home/zututukulipa/Desktop/barcode.txt";
            var file = File.Open(path, FileMode.Open);
            var data = new byte[file.Length];

            file.Read(data, 0, (int)file.Length);
            file.Close();
            SupportMaterial sm = new SupportMaterial
            {
                BinaryData      = data,
                MaterialName    = "TEST FILE",
                MaterialCreated = DateTime.Now,
                SubjectId       = 59,
                PageCount       = 1
            };

            return(await _service.AddMaterial(sm));
        }
Пример #3
0
        public void AddMaterial_AddEmptyFile_NotNull()
        {
            var mock     = new Mock <IRepository>();
            var material = new Material {
                Id = 1, Name = "RINAT", Category = (Category)1
            };
            Material ret = null;

            mock.Setup(repo => repo.FindByName("RINAT")).Returns(ret);
            MaterialService materialService = new MaterialService(new ConfigurationBuilder()
                                                                  .SetBasePath(Directory.GetCurrentDirectory())
                                                                  .AddJsonFile("appsettings.json")
                                                                  .Build(), mock.Object);
            IFormFile file = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("new")), 0, 0, "Data", "text1.txt");

            var result = materialService.AddMaterial(material, file);

            Assert.NotNull(result);
        }
Пример #4
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MaterialService svr = new MaterialService();

            string materialName = cboMaterialUser.Text.Trim().ToString();

            if (materialName.Equals(""))
            {
                Utils.ShowPrompt(MessageType.mtWarning, "领料员不能为空!\n");
                return;
            }
            string specifiedMaterialDate = ttSpecifiedMaterialDate.Text.Trim().ToString();

            if (specifiedMaterialDate.Equals(""))
            {
                Utils.ShowPrompt(MessageType.mtWarning, "领料日期不能为空!\n");
                return;
            }

            WaitDialogForm sdf = new WaitDialogForm("", "正在保存......");

            string materialCode = (cboMaterialUser.EditValue as CheckedListBoxItem).Value.ToString();

            List <T_PickedPlanDetails> ppDeatilsList = bsDetails.DataSource as List <T_PickedPlanDetails>;

            svr.AddMaterial(ppDeatilsList, materialCode, materialName, specifiedMaterialDate, Global.User);

            sdf.Close();
            if (svr.HasError)
            {
                Utils.ShowPrompt(MessageType.mtError, "发料计划保存失败:" + svr.Errors);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #5
0
        private void btnMaterialSql_Click(object sender, EventArgs e)
        {
            #region 数据验证
            if (this.txtCardId.Text.Trim().Length == 0)
            {
                MessageBox.Show("材料牌号不能为空!", "提示信息");
                this.txtCardId.Focus();
                return;
            }
            if (this.txtMaterialType.Text.Trim().Length == 0)
            {
                MessageBox.Show("材料类型不能为空!", "提示信息");
                this.txtMaterialType.Focus();
                return;
            }
            if (this.txtHeatType.Text.Trim().Length == 0)
            {
                MessageBox.Show("热处理方式不能为空!", "提示信息");
                this.txtHeatType.Focus();
                return;
            }
            if (this.txtHardVal.Text.Trim().Length == 0)
            {
                MessageBox.Show("材料硬度值不能为空!", "提示信息");
                this.txtHardVal.Focus();
                return;
            }
            if (this.txtContactVal.Text.Trim().Length == 0)
            {
                MessageBox.Show("接触疲劳极限值不能为空!", "提示信息");
                this.txtContactVal.Focus();
                return;
            }
            if (Common.DataValidate.IsNumber(this.txtContactVal.Text.Trim()))
            {
                MessageBox.Show("接触疲劳极限值有误,请重新输入!", "提示信息");
                this.txtContactVal.Focus();
                return;
            }
            if (this.txtBendVal.Text.Trim().Length == 0)
            {
                MessageBox.Show("弯曲疲劳极限值不能为空!", "提示信息");
                this.txtBendVal.Focus();
                return;
            }
            if (Common.DataValidate.IsNumber(this.txtBendVal.Text.Trim()))
            {
                MessageBox.Show("弯曲疲劳极限值有误,请重新输入!", "提示信息");
                this.txtBendVal.Focus();
                return;
            }

            #endregion
            #region 封装材料对象
            Materials objMaterial = new Materials()
            {
                MaterialCardId      = this.txtCardId.Text.Trim(),
                MaterialType        = this.txtMaterialType.Text.Trim(),
                HeatingType         = this.txtHeatType.Text.Trim(),
                HardnessValue       = this.txtHardVal.Text.Trim(),
                ContactFatigueLimit = this.txtContactVal.Text.Trim(),
                BendingFatigueLimit = this.txtBendVal.Text.Trim()
            };
            #endregion
            #region 调用后台数据访问方法添加对象
            try
            {
                if (1 == objMaterialService.AddMaterial(objMaterial))
                {
                    MessageBox.Show("添加成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            #endregion
        }