private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     if (CurrentConfig.Id == null)
     {
         //新增
         CurrentConfig.Created   = DateTime.Now;
         CurrentConfig.CreatedBy = App.User.UserCode;
         BllResult <int?> result = AppSession.Dal.InsertCommonModel <Config>(CurrentConfig);
         if (result.Success)
         {
             MessageBox.Show("新增成功");
             TxtConfigCode.IsReadOnly = true;
             CurrentConfig.Id         = result.Data;
         }
         else
         {
             MessageBox.Show($"新增失败:{result.Msg}");
         }
     }
     else
     {
         //更新
         CurrentConfig.Updated   = DateTime.Now;
         CurrentConfig.UpdatedBy = App.User.UserCode;
         BllResult result = AppSession.Dal.UpdateCommonModel <Config>(CurrentConfig);
         if (result.Success)
         {
             MessageBox.Show("更新成功");
         }
         else
         {
             MessageBox.Show($"更新失败:{result.Msg}");
         }
     }
 }
Example #2
0
        /// <summary>
        /// 写入或清除 ECS允许上料信号,True为写入,False为清除
        /// </summary>
        /// <param name="plc"></param>
        /// <param name="robot"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        protected BllResult SendLoadReadyToPlc(bool load_Ready, Equipment robot, IPLC plc, int pipeMaterial, int pipeLength, decimal pipeDiameter, decimal pipeThickness)
        {
            var operate       = load_Ready ? "写入" : "清除";
            var status        = load_Ready ? MachineMessageFlag.WCS回复允许上料.GetIndexString() : MachineMessageFlag.默认.GetIndexString();
            var WCSACKMessage = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMessage.ToString());

            var WCS_Pipe_Material  = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKMaterial.ToString());
            var WCS_Pipe_Length    = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKLength.ToString());
            var WCS_Pipe_Diameter  = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKDiameter.ToString());
            var WCS_Pipe_Thickness = robot.EquipmentProps.Find(t => t.EquipmentTypeTemplateCode == MachineProps.WCSACKThickness.ToString());

            WCS_Pipe_Material.Value  = pipeMaterial.ToString();
            WCS_Pipe_Length.Value    = pipeLength.ToString();
            WCS_Pipe_Diameter.Value  = pipeDiameter.ToString();
            WCS_Pipe_Thickness.Value = pipeThickness.ToString();
            WCSACKMessage.Value      = status.ToString();
            var propsToWriter = new List <EquipmentProp> {
                WCSACKMessage, WCS_Pipe_Material, WCS_Pipe_Length, WCS_Pipe_Diameter, WCS_Pipe_Thickness
            };

            BllResult plcResult = plc.Writes(propsToWriter);

            if (plcResult.Success)
            {
                Logger.Log($"{operate}设备【{robot.Name}】上料准备完成 信号成功", LogLevel.Success);
            }
            else
            {
                Logger.Log($"{operate}设备【{robot.Name}】上料准备完成 信号失败,写入PLC失败:原因:{plcResult.Msg}", LogLevel.Error);
            }
            return(plcResult);
        }
        private void Query()
        {
            string sql = "where 1=1 ";

            if (!String.IsNullOrWhiteSpace(TxtCode.Text))
            {
                sql += $" and code like '{TxtCode.Text}%'";
            }
            if (!String.IsNullOrWhiteSpace(TxtName.Text))
            {
                sql += $" and name like '{TxtName.Text}%'";
            }
            BllResult <int> result = AppSession.Dal.GetCommonModelCount <Dict>(sql);

            if (result.Success)
            {
                PageInfo.TotalCount = result.Data;
                BllResult <List <Dict> > a = AppSession.Dal.GetCommonModeByPageCondition <Dict>(PageInfo.PageIndex, PageInfo.PageSize, sql, "");
                if (a.Success)
                {
                    DGMain.ItemsSource   = a.Data;
                    TIMain.IsSelected    = true;
                    DGDetail.ItemsSource = null;
                }
                else
                {
                    MessageBox.Show($"查询失败{a.Msg}");
                }
            }
            else
            {
                MessageBox.Show($"查询失败{result.Msg}");
            }
        }
 private void BtnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (DGMain.SelectedItems == null || DGMain.SelectedItems.Count == 0)
     {
         MessageBox.Show("请至少选中一条数据");
     }
     else
     {
         if (MessageBox.Show("删除数据字典可能导致程序异常,是否继续?", "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             List <Dict> list = new List <Dict>();
             foreach (var item in DGMain.SelectedItems)
             {
                 list.Add((Dict)item);
             }
             BllResult result = AppSession.BllService.DeleteDictByIds(list.Select(t => t.Id.Value).ToList());
             if (result.Success)
             {
                 MessageBox.Show("删除成功");
             }
             else
             {
                 MessageBox.Show($"删除失败:{result.Msg}");
             }
             Query();
         }
     }
 }
        private void Query()
        {
            string sql = $"where 1=1";

            if (!String.IsNullOrWhiteSpace(txt_Code.Text.Trim()))
            {
                sql += $"and lineCode like {txt_Code.Text.Trim()}";
            }
            BllResult <int> countResult = AppSession.Dal.GetCommonModelCount <Station>(sql);

            if (countResult.Success)
            {
                PageInfo.TotalCount = countResult.Data;
                var res = AppSession.Dal.GetCommonModelByCondition <Station>(sql);
                if (res.Success)
                {
                    dgv_1.ItemsSource = res.Data;
                }
                else
                {
                    MessageBox.Show($"查询出错{res.Msg}");
                }
            }
            else
            {
                MessageBox.Show($"查询记录数出错{countResult.Msg}");
            }
        }
Example #6
0
 private void btn_Delete_Click(object sender, RoutedEventArgs e)
 {
     if (dgv_1.SelectedItems.Count == 0)
     {
         MessageBox.Show("请至少选中一条数据!");
     }
     else
     {
         if (MessageBox.Show("是否确认删除?这可能导致程序异常!", "警告", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             List <CarTask> list = new List <CarTask>();
             foreach (var item in dgv_1.SelectedItems)
             {
                 list.Add((CarTask)item);
             }
             BllResult result = AppSession.Dal.DeleteCommonModelByIds <CarTask>(list.Select(t => t.Id.Value).ToList());
             if (result.Success)
             {
                 MessageBox.Show("删除成功");
             }
             else
             {
                 MessageBox.Show("删除失败");
             }
             Query();
         }
     }
 }