private void InsertProject(DataTable dtProject)
        {
            foreach (DataRow row in dtProject.Rows)
            {
                string strId           = row["Index"].ToString();
                string strName         = row["Name"].ToString();
                string strManager      = row["ManagerName"].ToString();
                string strManagerTel   = row["ManagerTel"].ToString();
                string strAddress      = row["Address"].ToString();
                string strRefGroupName = row["RefGroupName"].ToString();

                if (GroupBll.IsNameExist(strName))
                {
                    continue;
                }

                GlareSysEfDbAndModels.ProjectInfo project = new GlareSysEfDbAndModels.ProjectInfo()
                {
                    Address     = strAddress,
                    CreateDt    = DateTime.Now,
                    Id          = 0,
                    IsDel       = 0,
                    UpdateDt    = DateTime.Now,
                    GroupId     = DataLoader.GetProjectIDByProjectName(strRefGroupName),
                    ManagerName = strManager,
                    ManagerTel  = strManagerTel,
                    OrgId       = DataLoader.GetOrgIDByProjectName(strRefGroupName),
                    ProjectName = strName
                };
                string strError;
                ProjectBll.AddAProject(ref project, out strError);
            }
        }
Esempio n. 2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            ProjectInfo mod = new ProjectInfo()
            {
                CreateDt    = DateTime.Now,
                Address     = "",
                GroupId     = (int)comboBoxGroup.SelectedValue,
                ManagerName = textBoxManagerName.Text,
                ManagerTel  = textBoxTel.Text,
                Id          = 0,
                IsDel       = 0,
                OrgId       = (int)comboBoxOrg.SelectedValue,
                UpdateDt    = DateTime.Now,
                ProjectName = textBoxName.Text
            };
            string strMsg;

            if (!ProjectBll.AddAProject(ref mod, out strMsg))
            {
                DialogResult = DialogResult.None;
                MessageBox.Show(strMsg);
            }
        }
        public string AddProject(string strParams)
        {
            string             strError;
            RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name,
                                                                           strParams, out strError);

            if (reqinfo == null)
            {
                return(strError);
            }

            ProjectInfo mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(ProjectInfo))
                              as ProjectInfo;

            if (mod == null)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError));
            }

            bool bResult = ProjectBll.AddAProject(ref mod, out strError);

            if (!bResult)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword));
            }

            // 成功返回成功标志及新增加的ID
            JsonResutlModelString result = new JsonResutlModelString()
            {
                ErrorDesc = "success",
                Info      = mod.Id.ToString(),
                Status    = true,
                StatusInt = 1
            };

            return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString)));
        }
        public ActionResult Add(GlareSysEfDbAndModels.ProjectInfo subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        subject.UpdateDt = DateTime.Now;
                        subject.CreateDt = DateTime.Now;
                        subject.IsDel    = 0;

                        subject.UpdateDt = DateTime.Now;
                        subject.CreateDt = DateTime.Now;
                        subject.IsDel    = 0;
                        string strMsg = string.Empty;
                        bool   b      = ProjectBll.AddAProject(ref subject, out strMsg);
                        if (b)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = strMsg,
                                Desc   = strMsg
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = strMsg,
                                Msg    = strMsg,
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                        //db.ProjectInfo.Add(subject);
                        //if (db.SaveChanges() > 0)
                        //{

                        //    objResult = new ResultHelper()
                        //    {
                        //        Status = true,
                        //        Ret = 0,
                        //        Obj = subject,
                        //        Msg = "Add  Success!",
                        //        Desc = "Add  Success!"
                        //    };
                        //}
                        //else
                        //{
                        //    objResult = new ResultHelper()
                        //    {
                        //        Desc = "Add  Faile,please try again.",
                        //        Msg = "Add  Faile,please try again.",
                        //        Obj = null,
                        //        Ret = -1,
                        //        Status = false
                        //    };
                        //}
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }