コード例 #1
0
        private void SetStatus()
        {
            if (!MessageBoxEx.ShowQuestion(string.Format("确定要{0}吗?", btnStatus.Caption)))
            {
                if (tb_workhours_Model.status.ToString() == ((int)DataSources.EnumStatus.Start).ToString())
                {
                    btnStatus.Caption = "启用";
                }
                else
                {
                    btnStatus.Caption = "停用";
                }
                return;
            }

            if (StatusSql())
            {
                MessageBoxEx.Show(btnStatus.Caption + "成功!");
                uc.BindgvWorkList();
                deleteMenuByTag(this.Tag.ToString(), uc.Name);
            }
            else
            {
                MessageBoxEx.ShowError(btnStatus.Caption + "失败!");
                if (tb_workhours_Model.status.ToString() == ((int)DataSources.EnumStatus.Start).ToString())
                {
                    btnStatus.Caption = "启用";
                }
                else
                {
                    btnStatus.Caption = "停用";
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void UCWorkingTimeAddOrEdit_SaveEvent(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtproject_name.Caption.Trim()))
                {
                    MessageBoxEx.Show("请填写维修项目名称!");
                    txtproject_name.Focus();
                    return;
                }

                if (MessageBoxEx.Show("确认要保存吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
                {
                    return;
                }

                Dictionary <string, string> dic = new Dictionary <string, string>();
                int datasorces = (int)SYSModel.DataSources.EnumDataSources.SELFBUILD;
                dic.Add("data_source", datasorces.ToString());                   //数据来源
                dic.Add("repair_type", ddlrepair_type.SelectedValue.ToString()); //项目分类
                dic.Add("project_num", lblproject_num.Text.Trim());              //维修项目编号
                dic.Add("project_name", txtproject_name.Caption.Trim());         //维修项目名称
                dic.Add("project_remark", txtproject_remark.Caption.Trim());     //项目备注
                if (radIsWorkTime.Checked)
                {
                    dic.Add("whours_type", "1");                             //工时类型,1工时,2定额
                    dic.Add("whours_num_a", txtwhours_num_a.Caption.Trim()); //A类工时数
                    dic.Add("whours_num_b", txtwhours_num_b.Caption.Trim()); //B类工时数
                    dic.Add("whours_num_c", txtwhours_num_c.Caption.Trim()); //C类工时数
                }
                else if (radIsQuota.Checked)
                {
                    dic.Add("whours_type", "2");                           //工时类型,1工时,2定额
                    dic.Add("quota_price", txtquota_price.Caption.Trim()); //定额单价(元)
                }

                //判断窗体状态
                if (windowStatus == WindowStatus.Add || windowStatus == WindowStatus.Copy)
                {
                    int StatusNum = (int)SYSModel.DataSources.EnumStatus.Start; //0停用,1启用
                    dic.Add("status", StatusNum.ToString());
                    dic.Add("enable_flag", "1");                                //标识未删除
                    dic.Add("whours_id", Guid.NewGuid().ToString());
                    dic.Add("create_by", GlobalStaticObj.UserID);
                    dic.Add("create_time", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
                    if (DBHelper.Submit_AddOrEdit("新增工时档案", "tb_workhours", "", "", dic))
                    {
                        MessageBoxEx.Show("保存成功!");
                        deleteMenuByTag(this.Tag.ToString(), uc.Name);
                    }
                    else
                    {
                        MessageBoxEx.Show("保存失败!");
                    }
                }
                else if (windowStatus == WindowStatus.Edit)//编辑
                {
                    dic.Add("update_by", GlobalStaticObj.UserID);
                    dic.Add("update_time", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
                    if (DBHelper.Submit_AddOrEdit("修改工时档案", "tb_workhours", "whours_id", workingTimeId, dic))
                    {
                        MessageBoxEx.Show("修改成功!");
                        uc.BindgvWorkList();
                        deleteMenuByTag(this.Tag.ToString(), uc.Name);
                    }
                    else
                    {
                        MessageBoxEx.Show("修改失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show("操作失败!");
                throw;
            }
        }