コード例 #1
0
ファイル: OrgController.cs プロジェクト: JasonDevStudio/Cnita
 public ActionResult Create(string Id=null)
 {
     var resultMsg = string.Empty;
     ModelOrganization model = new ModelOrganization();
     if (!string.IsNullOrWhiteSpace(Id))
     {
         LogicOrganization logic = new LogicOrganization();
         model = logic.OrganizationDetail(out resultMsg, int.Parse(Id));
     }
     return View(model);
 }
コード例 #2
0
ファイル: OrgController.cs プロジェクト: JasonDevStudio/Cnita
        public ActionResult Create(ModelOrganization model)
        {
            var resultMsg = string.Empty;
            var result = new ResultBase();

            var logic = new LogicOrganization();
            model.Status = "1";
            var res = logic.OrganizationInsertUpdate(out resultMsg, model);
            if (res > 0)
            {
                resultMsg = "操作成功!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "Goto");
            }
            else
            {
                resultMsg = "操作失败,请检查数据是否正确后重新操作!";
                ViewBag.CustomScript = UtilityScript.ShowMessage(resultMsg, isCreate: true, isSuccess: true, funName: "BtnShow");
            }
            return View(model);
        }
コード例 #3
0
        /// <summary>
        /// Model ��ֵ IDataReader
        /// </summary>
        private IList<ModelOrganization> GetModel(IDataReader dr)
        {
            var modelList = new List<ModelOrganization>();

            while (dr.Read())
            {
                var model = new ModelOrganization();
                model.Orgid = dr["OrgId"]== DBNull.Value ? 0 : Convert.ToInt32(dr["OrgId"]);
                model.Orgname = dr["OrgName"]== DBNull.Value ? string.Empty : dr["OrgName"].ToString();
                model.Orgenname = dr["OrgEnName"]== DBNull.Value ? string.Empty : dr["OrgEnName"].ToString();
                model.Address = dr["Address"]== DBNull.Value ? string.Empty : dr["Address"].ToString();
                model.Addressen = dr["AddressEn"]== DBNull.Value ? string.Empty : dr["AddressEn"].ToString();
                model.Zipcode = dr["ZipCode"]== DBNull.Value ? string.Empty : dr["ZipCode"].ToString();
                model.Internetsite = dr["InternetSite"]== DBNull.Value ? string.Empty : dr["InternetSite"].ToString();
                model.Natureofbusiness = dr["NatureOfBusiness"]== DBNull.Value ? string.Empty : dr["NatureOfBusiness"].ToString();
                model.Fixedassets = dr["FixedAssets"]== DBNull.Value ? string.Empty : dr["FixedAssets"].ToString();
                model.Legalperson = dr["LegalPerson"]== DBNull.Value ? string.Empty : dr["LegalPerson"].ToString();
                model.Post = dr["Post"]== DBNull.Value ? string.Empty : dr["Post"].ToString();
                model.Tel = dr["Tel"]== DBNull.Value ? string.Empty : dr["Tel"].ToString();
                model.Fax = dr["Fax"]== DBNull.Value ? string.Empty : dr["Fax"].ToString();
                model.Phone = dr["Phone"]== DBNull.Value ? string.Empty : dr["Phone"].ToString();
                model.Email = dr["Email"]== DBNull.Value ? string.Empty : dr["Email"].ToString();
                model.Contact = dr["Contact"]== DBNull.Value ? string.Empty : dr["Contact"].ToString();
                model.Contactpost = dr["ContactPost"]== DBNull.Value ? string.Empty : dr["ContactPost"].ToString();
                model.Contacttel = dr["ContactTel"]== DBNull.Value ? string.Empty : dr["ContactTel"].ToString();
                model.Contactfax = dr["ContactFax"]== DBNull.Value ? string.Empty : dr["ContactFax"].ToString();
                model.Contactphone = dr["ContactPhone"]== DBNull.Value ? string.Empty : dr["ContactPhone"].ToString();
                model.Contactemail = dr["ContactEmail"]== DBNull.Value ? string.Empty : dr["ContactEmail"].ToString();
                model.Unittype = dr["UnitType"]== DBNull.Value ? string.Empty : dr["UnitType"].ToString();
                model.Productapplications = dr["ProductApplications"]== DBNull.Value ? string.Empty : dr["ProductApplications"].ToString();
                model.Processcategory = dr["ProcessCategory"]== DBNull.Value ? string.Empty : dr["ProcessCategory"].ToString();
                model.Membershiplevel = dr["MembershipLevel"]== DBNull.Value ? string.Empty : dr["MembershipLevel"].ToString();
                model.Introduction = dr["Introduction"]== DBNull.Value ? string.Empty : dr["Introduction"].ToString();
                model.Createdate = dr["CreateDate"]== DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(dr["CreateDate"]);
                modelList.Add(model);
            }
            return modelList;
        }
コード例 #4
0
        /// <summary>
        ///  ��ѯʵ��
        /// </summary>
        /// <param name="orgid">ModelOrgid ���</param>
        /// <returns>ModelOrganization</returns>
        public ModelOrganization OrganizationDetail(out string resultMsg, string authorizeInfo, Int32 orgid)
        {
            resultMsg = string.Empty;
            var model = new ModelOrganization();
            try
            {
                //�洢��������
                string sql = "usp_organization_select_detail_by_orgid";

                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "ORGID", ParameterValue = orgid, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });

                //��ѯִ��
                using (IDataReader dr = DBHelper.ExecuteReader(authorizeInfo,sql, true, parm))
                {
                    IList<ModelOrganization> list = GetModel(dr);
                    model = list.First();
                }
            }
            catch (AuthorizeException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return model;
        }
コード例 #5
0
        /// <summary>
        /// ���� ���/����
        /// </summary>
        /// <param name="organization">ʵ��</param>
        /// <returns>ִ�н��</returns>
        public int OrganizationInsertUpdate(out string resultMsg, string authorizeInfo, ModelOrganization organization, DbTransaction tran = null)
        {
            resultMsg = string.Empty;
            int res = 0;
            try
            {
                //�洢��������
                string sql = "USP_ORGANIZATION_INSERT_UPDATE";
                //�������
                IList<DBParameter> parm = new List<DBParameter>();
                parm.Add(new DBParameter() { ParameterName = "ORGID", ParameterValue = organization.Orgid, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.Int32 });
                parm.Add(new DBParameter() { ParameterName = "ORGNAME", ParameterValue = organization.Orgname, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "ORGENNAME", ParameterValue = organization.Orgenname, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "ADDRESS", ParameterValue = organization.Address, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "ADDRESSEN", ParameterValue = organization.Addressen, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "ZIPCODE", ParameterValue = organization.Zipcode, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "INTERNETSITE", ParameterValue = organization.Internetsite, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "NATUREOFBUSINESS", ParameterValue = organization.Natureofbusiness, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "FIXEDASSETS", ParameterValue = organization.Fixedassets, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "LEGALPERSON", ParameterValue = organization.Legalperson, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "POST", ParameterValue = organization.Post, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "TEL", ParameterValue = organization.Tel, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "FAX", ParameterValue = organization.Fax, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "PHONE", ParameterValue = organization.Phone, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "EMAIL", ParameterValue = organization.Email, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACT", ParameterValue = organization.Contact, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACTPOST", ParameterValue = organization.Contactpost, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACTTEL", ParameterValue = organization.Contacttel, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACTFAX", ParameterValue = organization.Contactfax, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACTPHONE", ParameterValue = organization.Contactphone, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "CONTACTEMAIL", ParameterValue = organization.Contactemail, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "UNITTYPE", ParameterValue = organization.Unittype, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "PRODUCTAPPLICATIONS", ParameterValue = organization.Productapplications, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "PROCESSCATEGORY", ParameterValue = organization.Processcategory, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "MEMBERSHIPLEVEL", ParameterValue = organization.Membershiplevel, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "INTRODUCTION", ParameterValue = organization.Introduction, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });
                parm.Add(new DBParameter() { ParameterName = "STATUS", ParameterValue = organization.Status, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String });

                //����/����ִ��
                res = DBHelper.ExecuteNonQuery(authorizeInfo,sql, true, parm, tran);
                foreach (var item in parm)
                {
                    //��ȡ�������ֵ
                    if (item.ParameterName == "resultMsg")
                    {
                        resultMsg = item.ParameterValue.ToString();
                        break;
                    }
                }
            }
            catch (AuthorizeException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                if(tran != null)
                    tran.Rollback();
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }
            return res;
        }