Ejemplo n.º 1
0
        /// <summary>
        /// 材料耗用清单行数据行单击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gvUsedMaterialListMain_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            this.gcUseMaterialList.DataSource = null;
            State = ControlState.Read;
            OnAfterStateChanged(State);
            UseMaterial _material = new UseMaterial();
            DataTable   dt        = new DataTable();
            string      key       = gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_DETAIL_KEY").ToString();

            dt = _material.GetMaterialDetailByKey(key).Tables[0];
            gcUseMaterialList.DataSource = _material.GetMaterialDetailByKey(key).Tables[0];
            txtMaterialLot.Text          = dt.Rows[0]["MATERIAL_LOT"].ToString();
            cmbOperationName.Text        = gvUsedMaterialListMain.GetFocusedRowCellValue("ROUTE_OPERATION_NAME").ToString();
            //cmbOperationName.Text = dt.Rows[0]["ROUTE_OPERATION_NAME"].ToString();
            //cmbFactoryRoom.EditValue = gvUsedMaterialListMain.GetFocusedRowCellValue("LOCATION_NAME").ToString();
            cmbFactoryRoom.EditValue = dt.Rows[0]["LOCATION_KEY"].ToString();
            //cmbEquipmentName.EditValue = gvUsedMaterialListMain.GetFocusedRowCellValue("EQUIPMENT_NAME").ToString();
            cmbEquipmentName.EditValue = dt.Rows[0]["EQUIPMENT_KEY"].ToString();
            cmbShiftName.EditValue     = dt.Rows[0]["SHIFT_NAME"].ToString();
            txtUseDateTime.Text        = dt.Rows[0]["USED_TIME"].ToString();
            txtOperator.Text           = dt.Rows[0]["OPERATOR"].ToString();
            //modi  by chao.pang 来料接收程序修改引发的只记录材料批次号,不扣减数量
            gvMain.Columns[9].OptionsColumn.AllowEdit  = false;
            gvMain.Columns[10].OptionsColumn.AllowEdit = false;
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// 但前班次信息
        ///// </summary>
        //public void GetNowShift()
        //{
        //    DataTable dataTable = new DataTable();
        //    try
        //    {
        //        //创建远程调用的工厂对象。
        //        IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject();
        //        if (null != serverFactory)//工厂对象不为null
        //        {
        //            //调用远程方法,根据分类名和列名从数据库中查询基础数据。
        //            dataTable = serverFactory.CreatIReceiveMaterialEngine().GetShiftName();

        //            if (dataTable.Rows.Count > 0)
        //            {
        //                cmbBanCi.EditValue = dataTable.Rows[0][0].ToString().Trim();
        //            }
        //        }
        //    }
        //    finally
        //    {

        //    }
        //}

        /// <summary>
        /// 设备名称绑定
        /// </summary>
        public void GetEquipment()
        {
            //绑定设备名称
            #region
            string      operationname  = cmbGongXuName.Text;
            string      cmbfactoryroom = cmbFactoryRoomName.Text;
            UseMaterial _material      = new UseMaterial();
            ////根据根据工序车间获取设备信息。
            DataSet dsMaterial = _material.GetEquipmentInfo(operationname, cmbfactoryroom);
            if (_material.ErrorMsg.Length < 1)   //如果执行查询失败。
            {
                if (dsMaterial.Tables.Count > 0) //查询结果数据集中有表。
                {
                    //绑定工厂车间数据到窗体控件。
                    //dsMaterial.Tables[0].Rows.Add();
                    dsMaterial.Tables[0].Rows.InsertAt(dsMaterial.Tables[0].NewRow(), 0);
                    cmbEquipmentName.Properties.DataSource    = dsMaterial.Tables[0];
                    cmbEquipmentName.Properties.DisplayMember = "EQUIPMENT_NAME";
                    cmbEquipmentName.Properties.ValueMember   = "EQUIPMENT_KEY";
                    //线别表中有数据,设置窗体控件的默认索引为0。
                    if (dsMaterial.Tables[0].Rows.Count > 0)
                    {
                        cmbEquipmentName.ItemIndex = -1;
                    }
                }
            }
            else
            {
                MessageService.ShowError(_material.ErrorMsg);
            }
            #endregion
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 绑定数据表
        /// </summary>
        public void CodeGridDataBind()
        {
            string      operations = PropertyService.Get(PROPERTY_FIELDS.OPERATIONS);
            string      stores     = PropertyService.Get(PROPERTY_FIELDS.STORES);
            UseMaterial _material  = new UseMaterial();

            gcUsedMaterialList.MainView   = gvUsedMaterialListMain;
            gcUsedMaterialList.DataSource = _material.GetMaterialUsed(operations, stores).Tables[0];
            gvMain.BestFitColumns();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 界面载入事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UseMaterialListCtrl_Load(object sender, EventArgs e)
 {
     #region
     UseMaterial _material = new UseMaterial();
     if (_material.ErrorMsg.Length < 1)//如果执行查询失败。
     {
         gcUsedMaterialList.MainView   = gvUsedMaterialListMain;
         gcUsedMaterialList.DataSource = _material.GetAllMaterialUsed().Tables[0];
         gvUsedMaterialListMain.BestFitColumns();
     }
     else
     {
         MessageService.ShowError(_material.ErrorMsg);
     }
     #endregion
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 绑定数据到数据表
 /// </summary>
 public void BindDateGrid()
 {
     #region
     UseMaterial _material = new UseMaterial();
     if (_material.ErrorMsg.Length < 1)//如果执行查询失败。
     {
         gcUsedMaterialList.MainView   = gvUsedMaterialListMain;
         gcUsedMaterialList.DataSource = _material.GetStoreMaterialDetail(_materialLot, _gongXuName, _wuLiaoNumber,
                                                                          _factoryRoomName, _wuLiaoMiaoShu, _equipmentName, _gongYingShang, _banCi, _lineCang, _jobNumber, _startTime,
                                                                          _endTime, _stores, _operations).Tables[0];
         gvUsedMaterialListMain.BestFitColumns();
     }
     else
     {
         MessageService.ShowError(_material.ErrorMsg);
     }
     #endregion
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbUpdate_Click(object sender, EventArgs e)
        {
            UseMaterial _material = new UseMaterial();
            DataSet     ds        = _material.GetMaterialDetailByMaterialLot(txtMaterialLot.Text.Trim(), gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_KEY").ToString());

            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    State = ControlState.Edit;
                    OnAfterStateChanged(State);
                    gvMain.Columns[9].OptionsColumn.AllowEdit  = true;
                    gvMain.Columns[10].OptionsColumn.AllowEdit = true;
                }
                else
                {
                    MessageService.ShowMessage("材料耗用已结账不能修改!", "${res:Global.SystemInfo}");
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(StringParser.Parse("确定要删除吗?"),
                                StringParser.Parse("${res:Global.SystemInfo}"), MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                UseMaterial _material = new UseMaterial();
                //根据物料批次号和耗用主键获取状态是否为1  状态 0:已作废 1:未结账 2:已结账
                DataSet ds = _material.GetMaterialDetailByMaterialLot(txtMaterialLot.Text.Trim(), gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_KEY").ToString());
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string materialLot      = txtMaterialLot.Text.Trim();
                        string materialUsedKey  = gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_KEY").ToString();
                        string materialUsedKey1 = gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_DETAIL_KEY").ToString();
                        if (_material.DeleteMaterital(materialLot, materialUsedKey, materialUsedKey1) == true)
                        {//通过物料批号和耗用主键来删除和修改表值
                            //绑定工序
                            BindOperation();

                            //绑定车间
                            BindFactoryRoom();
                            BindShiftName();

                            //绑定材料历史耗用数据表数据
                            CodeGridDataBind();
                            State = ControlState.New;
                            OnAfterStateChanged(State);
                        }
                    }
                    else
                    {
                        MessageService.ShowMessage("如果材料耗用已结账不能删除!", "${res:Global.SystemInfo}");
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (this.gvMain.State == GridState.Editing && this.gvMain.IsEditorFocused &&
                this.gvMain.EditingValueModified)
            {
                this.gvMain.SetFocusedRowCellValue(this.gvMain.FocusedColumn, this.gvMain.EditingValue);
            }
            this.gvMain.UpdateCurrentRow();

            if (MessageBox.Show(StringParser.Parse("确定要保存吗?"),
                                StringParser.Parse("${res:Global.SystemInfo}"), MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (gcUseMaterialList.DataSource == null)
                {
                    MessageService.ShowMessage("本次耗用列表不能为空!", "${res:Global.SystemInfo}");
                    return;
                }
                if (string.IsNullOrEmpty(cmbOperationName.Text))
                {
                    MessageService.ShowMessage("工序不能为空!", "${res:Global.SystemInfo}");
                    return;
                }
                if (string.IsNullOrEmpty(cmbFactoryRoom.Text))
                {
                    MessageService.ShowMessage("车间不能为空!", "${res:Global.SystemInfo}");
                    return;
                }
                if (string.IsNullOrEmpty(cmbEquipmentName.Text))
                {
                    MessageService.ShowMessage("设备不能为空!", "${res:Global.SystemInfo}");
                    return;
                }
                if (string.IsNullOrEmpty(txtUseDateTime.Text))
                {
                    MessageService.ShowMessage("耗用时间不能为空!", "${res:Global.SystemInfo}");
                    return;
                }
                UseMaterial _material = new UseMaterial();

                Hashtable hashTable = new Hashtable();
                hashTable.Add("CREATOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME));
                hashTable.Add("CREATE_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE));
                hashTable.Add("EDITOR", PropertyService.Get(PROPERTY_FIELDS.USER_NAME));
                hashTable.Add("EDIT_TIMEZONE", PropertyService.Get(PROPERTY_FIELDS.TIMEZONE));
                DataTable tableParam = FanHai.Hemera.Share.Common.CommonUtils.ParseToDataTable(hashTable);
                tableParam.TableName = "HASH";

                if (State == ControlState.New)
                {//判断状态为新增
                    DataTable dtDetailTable = new DataTable();
                    DataView  dv            = gvMain.DataSource as DataView;
                    if (dv != null)
                    {
                        dtDetailTable = dv.Table;
                    }


                    DataTable dtMaterialUsed = new DataTable();
                    dtMaterialUsed.Columns.Add("OPERATION_NAME");
                    dtMaterialUsed.Columns.Add("EQUIPMENT_KEY");
                    dtMaterialUsed.Columns.Add("SHIFT_NAME");
                    dtMaterialUsed.Columns.Add("USED_TIME");
                    dtMaterialUsed.Columns.Add("OPERATOR");
                    dtMaterialUsed.Columns.Add("REASON");
                    DataRow dr = dtMaterialUsed.NewRow();
                    dr["OPERATION_NAME"] = cmbOperationName.EditValue.ToString();
                    string equipmentName = cmbEquipmentName.Text;
                    string equipmentKey  = cmbEquipmentName.Properties.GetKeyValueByDisplayText(equipmentName).ToString();
                    dr["EQUIPMENT_KEY"] = equipmentKey;
                    dr["SHIFT_NAME"]    = cmbShiftName.EditValue;
                    dr["USED_TIME"]     = txtUseDateTime.EditValue;
                    dr["OPERATOR"]      = txtOperator.Text;
                    dr["REASON"]        = memoReason.Text;
                    dtMaterialUsed.Rows.Add(dr);

                    DataSet dsSetIn = new DataSet();
                    dtDetailTable.TableName = "MATERIAL_USED_DATAIL";
                    dsSetIn.Merge(dtDetailTable);
                    dtMaterialUsed.TableName = "MATERIAL_USED";
                    dsSetIn.Merge(dtMaterialUsed);
                    dsSetIn.Merge(tableParam);


                    if (!_material.InsertMaterial(dsSetIn))
                    {
                        MessageService.ShowMessage(_material.ErrorMsg);
                    }
                    else
                    {
                        MessageService.ShowMessage("新增材料耗用成功。");
                        tsbNew_Click(sender, e);
                    }
                }
                else if (State == ControlState.Edit)
                {
                    string materialLot      = txtMaterialLot.Text.Trim();
                    string materialUsedKey  = gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_KEY").ToString();
                    string materialUsedKey1 = gvUsedMaterialListMain.GetFocusedRowCellValue("MATERIAL_USED_DETAIL_KEY").ToString();
                    string operationName    = cmbOperationName.EditValue.ToString();
                    string equipmentName    = cmbEquipmentName.Text;
                    string equipmentKey     = cmbEquipmentName.Properties.GetKeyValueByDisplayText(equipmentName).ToString();
                    string usedDateTime     = txtUseDateTime.Text;
                    string strTime          = gvMain.GetRowCellValue(0, "STIR_TIME").ToString();
                    string printQty         = gvMain.GetRowCellValue(0, "PRINT_QTY").ToString();
                    //修改材料耗用历史记录(材料明细表和材料表)
                    if (_material.UpDateMaterialUsedAndDetail(materialLot, materialUsedKey, materialUsedKey1, operationName, equipmentKey,
                                                              usedDateTime, strTime, printQty, tableParam) == true)
                    {
                        tsbNew_Click(sender, e);
                    }
                }
            }
            this.gvMain.BestFitColumns();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 物料批号回车事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtMaterialLot_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                string strMaterialLot = txtMaterialLot.Text.Trim();
                if (string.IsNullOrEmpty(strMaterialLot))
                {
                    MessageService.ShowMessage("请输入物料批号!", "${res:Global.SystemInfo}");
                    return;
                }
                //判断输入的物料批号是否重复?
                DataView dv = gvMain.DataSource as DataView;
                if (dv != null)
                {
                    int length = dv.Table.Select("MATERIAL_LOT='" + strMaterialLot + "'").Length;
                    if (length > 0)
                    {
                        MessageService.ShowMessage("耗用列表中已存在批号为[" + strMaterialLot + "]的物料,不能重复添加。", "${res:Global.SystemInfo}");
                        return;
                    }
                }
                //获取物料批号对应的物料信息。
                UseMaterial _material         = new UseMaterial();
                DataSet     materialByLotOpFa = _material.GetMaterialByLotOpFa(txtMaterialLot.Text.Trim(), cmbOperationName.Text.Trim(), cmbFactoryRoom.Text.Trim());
                if (materialByLotOpFa.Tables.Count > 0)
                {
                    if (materialByLotOpFa.Tables[0].Rows.Count > 0)
                    {
                        gvMain.Columns[9].OptionsColumn.AllowEdit  = true;
                        gvMain.Columns[10].OptionsColumn.AllowEdit = true;
                        materialByLotOpFa.Tables[0].Columns.Add(new DataColumn("STIR_TIME", typeof(DateTime)));
                        materialByLotOpFa.Tables[0].Columns.Add(new DataColumn("PRINT_QTY", typeof(string)));


                        gcUseMaterialList.MainView = gvMain;

                        DataTable dt01 = new DataTable();
                        if (gvMain.DataSource == null)
                        {
                            dt01 = materialByLotOpFa.Tables[0];
                            if (!dt01.Columns.Contains("ROWNUMBER"))
                            {
                                dt01.Columns.Add("ROWNUMBER");
                            }
                            dt01.Rows[0]["ROWNUMBER"] = 1;

                            gcUseMaterialList.DataSource = dt01;
                            gvMain.BestFitColumns();
                        }

                        else if (gvMain.DataSource != null)
                        {
                            DataTable dt = ((DataView)gvMain.DataSource).Table;
                            dt.ImportRow(materialByLotOpFa.Tables[0].Rows[0]);

                            if (!dt.Columns.Contains("ROWNUMBER"))
                            {
                                dt.Columns.Add("ROWNUMBER");
                            }

                            for (int i = 1; i < dt.Rows.Count + 1; i++)
                            {
                                dt.Rows[i - 1]["ROWNUMBER"] = i.ToString();
                            }

                            gcUseMaterialList.DataSource = dt;
                            gvMain.BestFitColumns();
                        }
                        else
                        {
                            gcUseMaterialList.DataSource = materialByLotOpFa.Tables[0];
                        }
                        txtMaterialLot.Text = "";
                    }
                    else
                    {
                        MessageService.ShowMessage("没有物料信息!", "${res:Global.SystemInfo}");
                    }
                }
                else
                {
                    MessageService.ShowError(_material.ErrorMsg);
                }
            }
            this.gvMain.BestFitColumns();
        }