private void btn_Modity_Click(object sender, EventArgs e) { string _price = txt_Price.Text.Trim(); if (!ValidateService.IsNumber(_price)) // 项目 Common 的 ValidateService 类 { MessageBox.Show("价格格式错误!"); txt_Price.Focus(); return; } //if (_model.Exists(_name)) //{ // MessageBox.Show("该名称已存在!"); // txt_Price.Focus(); // return; //} _model.Price = decimal.Parse(_price); bool re = _model.Update(); if (re) { MessageBox.Show("修改成功!"); this._isTrue = true; this.Close(); } else { MessageBox.Show("修改失败!"); } }
private void btn_Add_Click(object sender, EventArgs e) { Norm user = new Norm(); string _name = txt_Name.Text.Trim(); if (!ValidateService.IsNumber(_name)) // 项目 Common 的 ValidateService 类 { MessageBox.Show("必须为数字!"); txt_Name.Focus(); return; } if (user.Exists(_name)) { MessageBox.Show("该规格已存在!"); txt_Name.Focus(); return; } user.NormName = _name; int re = user.Add(); if (re > 0) { MessageBox.Show("添加成功!"); txt_Name.Text = ""; txt_Name.Focus(); BindDGV(); } else { MessageBox.Show("添加失败!"); } }
/// <summary> /// 点击单元格的内容时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "确定要删除吗?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value; if (v != null) { Norm no = new Norm(); if (no.IsRelation(v.ToString())) { MessageBox.Show("该记录已被使用,禁止删除!"); return; } bool re = no.Delete(v.ToString()); if (re) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } else if (e.ColumnIndex == dataGridView1.Columns["cModity"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cID"].Value; if (ValidateService.IsNumber(v)) { Norm no = new Norm(); no.GetModel((int)v); frmGoodsNormUpdate f = new frmGoodsNormUpdate(no); f.ShowDialog(); if (f._isTrue) { BindDGV(); } } } }
private void btn_Add_Click(object sender, EventArgs e) { Level user = new Level(); string _name = txt_Name.Text.Trim(); if (string.IsNullOrEmpty(_name)) { MessageBox.Show("名称不能为空!"); txt_Name.Focus(); return; } if (user.Exists(_name)) { MessageBox.Show("该名称已存在!"); txt_Name.Focus(); return; } string _price = txt_Price.Text.Trim(); if (!ValidateService.IsNumber(_price)) { MessageBox.Show("价格格式不正确!"); txt_Price.Focus(); return; } user.LevelName = _name; user.Price = decimal.Parse(_price); int re = user.Add(); if (re > 0) { MessageBox.Show("添加成功!"); txt_Name.Text = ""; txt_Name.Focus(); BindDGV(); } else { MessageBox.Show("添加失败!"); } }
private void btn_Add_Click(object sender, EventArgs e) { string modelStr = txt_Model.Text.Trim(); string macStr = cbx_Machine.Text; string bigStr = cbx_Big.Text; string cntStr = cbx_Cnt.Text; string lenStr = txt_Length.Text.Trim(); if (string.IsNullOrEmpty(cntStr) || string.IsNullOrEmpty(bigStr) || string.IsNullOrEmpty(macStr)) { MessageBox.Show("卷数或件数格式不正确!"); cbx_Cnt.Focus(); return; } if (string.IsNullOrEmpty(modelStr)) { MessageBox.Show("请输入成品型号!"); txt_Model.Focus(); return; } if (!ValidateService.IsNumber(lenStr)) { MessageBox.Show("米数不正确!"); txt_Length.Focus(); return; } try { InW m = new InW(); m.Model = modelStr; m.NormName = cbx_Norm.SelectedValue.ToString(); m.Machine = int.Parse(macStr); m.BigCnt = int.Parse(bigStr); m.Cnt = int.Parse(cntStr); m.Length = int.Parse(lenStr); m.Batch = GenBatchNO(); List <string> barList = GenBarcode(m.Machine, m.BigCnt, m.Cnt); m.Barcode = barList[0] + "~" + barList[barList.Count - 1]; m.Operator = Global.userName; m.InTime = dtp_InTime.Value; int re = m.Add(barList); if (re > 0) { MessageBox.Show("入库成功!"); BindDGV(); } else { MessageBox.Show("入库失败!"); } } catch (Exception ex) { if (ex.Message.Contains("99")) { MessageBox.Show("每天同一规格成品入仓数量不能大于99件!"); //txt_Cnt.Focus(); } else { MessageBox.Show("系统异常! 详细:" + ex.Message); } } }
private void LoadExcel(string path) { try { DataTable dt = null; try { dt = ExcelService.ImportDataTableFromExcel(path, int.Parse(ddl_Name.SelectedItem.Value), 0); } catch { } if (dt != null) { EmployeeBLL iBLL = new EmployeeBLL(); IList <Employee> iList = new List <Employee>(); IList <int> iListErrorRowNumber = new List <int>(); IList <int> iListFailRowNumber = new List <int>(); int _OrganID = Convert.ToInt32(ddl_Organ.SelectedValue); string _InputBy = Session["UserID"].ToString(); int count = 0; int row = 0; foreach (DataRow dr in dt.Rows) { //excel内容 string _UserName = dr["姓名"].ToString(); string _PQ = dr["片区"].ToString(); string _DZ = dr["大组"].ToString(); string _XZ = dr["小组"].ToString(); string _RoleName = dr["梯队任职"].ToString(); string _IsPrivateStr = dr["是否公估"].ToString(); if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PQ) || !ValidateService.IsNumber(_DZ) || string.IsNullOrEmpty(_XZ) || string.IsNullOrEmpty(_RoleName) || string.IsNullOrEmpty(_IsPrivateStr)) { row++; iListErrorRowNumber.Add(row); continue; } bool _isPrivate = _IsPrivateStr == "否" ? false : true; //添加用户 string _userID = AddUser(_UserName, _OrganID); //添加组织 string _PQname = "", _DZname = "", _XZname = ""; string _PQcode = "", _DZcode = "", _XZcode = ""; if (_PQ != "0") { _PQname = _PQ + "片区"; _PQcode = AddPosition(_PQname, _OrganID, "市级管理层"); } else { _PQcode = AddPosition("市级管理层", _OrganID, "市级管理层"); } if (_DZ != "0") { _DZname = _PQname + _DZ + "大组"; } _DZcode = AddPosition(_DZname, _OrganID, _PQname); if (_XZ != "0") { if (_DZname != string.Empty) { _XZname = _DZname + _XZ + "小组"; } else { _XZname = _PQname + _XZ + "小组"; } } _XZcode = AddPosition(_XZname, _OrganID, _DZname); string _posiCode = ""; if (!string.IsNullOrEmpty(_PQcode)) { _posiCode = _PQcode; } if (!string.IsNullOrEmpty(_DZcode)) { _posiCode = _DZcode; } if (!string.IsNullOrEmpty(_XZcode)) { _posiCode = _XZcode; } //添加组织关联 if (!string.IsNullOrEmpty(_posiCode)) { List <string> posiList = new List <string>(); posiList.Add(_posiCode); int rePU = new PositionBLL().AddPosi2User(_userID, posiList); } //添加角色 string _roleCode = AddRole(_RoleName, _OrganID); //添加角色关联 if (!string.IsNullOrEmpty(_roleCode)) { List <string> roleList = new List <string>(); roleList.Add(_roleCode); int reRU = new UserBLL().AddRole2User(_userID, roleList); } //添加员工 AddEmployee(_UserName, _OrganID, _isPrivate); count++; } string msg = ""; if (count > 0) { msg = msg + "成功上传数据" + count + "条!"; msg = msg + "\\n"; } if (iListErrorRowNumber.Count > 0) { msg = msg + "数据不全或有误共" + iListErrorRowNumber.Count + "条,请核对以下行号的数据是否有误,并进行修改!"; msg = msg + "\\n 有误行号:"; foreach (int i in iListErrorRowNumber) { msg += i + ","; } msg = msg + "\\n"; } if (iListFailRowNumber.Count > 0) { msg = msg + "车架号已存在共" + iListFailRowNumber.Count + "条!"; msg = msg + "\\n 已存在行号:"; foreach (int i in iListFailRowNumber) { msg += i + ","; } msg = msg + "\\n"; } UtilityService.Alert(this.Page, msg); } } catch (Exception ex) { UtilityService.Alert(this.Page, "导入失败!,详细:" + ex.Message); } }