Exemplo n.º 1
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            try
            {
                if (btn_Delete.Tag == null)
                {
                    return;
                }

                UniversalControlLibrary.FileOperationService.File_Delete(new Guid(btn_Delete.Tag.ToString()),
                                                                         GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>
                                                                             (BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));


                HR_Train_Courseware ware = new HR_Train_Courseware();

                ware.ID = Convert.ToInt32(txtCoursewareName.Tag);
                _ServiceBasicInfo.Operation_Courseware(ware);
                MessageDialog.ShowPromptMessage("删除成功");
                dgv_Courseware.DataSource = _ServiceBasicInfo.GetTable_Ware(_CourseInfo.ID);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void Operation_Ware(HR_Train_Courseware obj)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                var varData = from a in ctx.HR_Train_Courseware
                              where a.ID == obj.ID
                              select a;

                if (varData.Count() == 1)
                {
                    ctx.HR_Train_Courseware.DeleteAllOnSubmit(varData);
                }
                else if (varData.Count() == 0)
                {
                    ctx.HR_Train_Courseware.InsertOnSubmit(obj);
                }
                else
                {
                    throw new Exception("数据不唯一");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid guid = Guid.NewGuid();
                    FileOperationService.File_UpLoad(guid, openFileDialog1.FileName,
                                                     GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>
                                                         (BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));

                    HR_Train_Courseware ware = new HR_Train_Courseware();

                    ware.CourseID       = _CourseInfo.ID;
                    ware.CoursewareName = txtCoursewareName.Text;
                    ware.FileUnique     = guid;
                    _ServiceBasicInfo.Operation_Courseware(ware);

                    MessageDialog.ShowPromptMessage("添加成功");
                    dgv_Courseware.DataSource = _ServiceBasicInfo.GetTable_Ware(_CourseInfo.ID);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Exemplo n.º 4
0
        public void Operation_Courseware(HR_Train_Courseware obj)
        {
            try
            {
                DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

                HR_Train_Courseware temp = new HR_Train_Courseware();

                var varData = from a in ctx.HR_Train_Courseware
                              where a.ID == obj.ID
                              select a;

                if (varData.Count() == 0)
                {
                    ctx.HR_Train_Courseware.InsertOnSubmit(obj);
                }
                else if (varData.Count() == 1)
                {
                    if (obj.CoursewareName == null)
                    {
                        ctx.HR_Train_Courseware.DeleteOnSubmit(varData.Single());
                    }
                    else
                    {
                        temp = varData.Single();

                        temp.CoursewareName = obj.CoursewareName;
                        temp.CourseID       = obj.CourseID;
                        temp.FileUnique     = obj.FileUnique;
                    }
                }
                else
                {
                    throw new Exception("记录数不唯一");
                }

                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }