public void InsertData(string currUser, InsuranceCompanyModel oClass)
        {
            strSql = strSql + "INSERT INTO " + TABLE_NAME + " (" +
                     COLUMN_CODE + ", " +
                     COLUMN_COMPANY_NAME + ", " +
                     COLUMN_CONTACT_PERSON + ", " +
                     COLUMN_ADDRESS + ", " +
                     COLUMN_EMAIL + ", " +
                     COLUMN_PHONE + ", " +
                     COLUMN_COUNTRY_CODE + ", " +
                     COLUMN_DATE_ACCREDIT + ", " +
                     COLUMN_DATE_EXPIRE + ", " +
                     "created_by, created_date, updated_by, updated_date) ";
            strSql = strSql + "values ('" +
                     oClass.Code + "', '" +
                     oClass.CompanyName.Replace("'", "") + "', '" +
                     oClass.ContactPerson.Replace("'", "") + "', '" +
                     oClass.Address.Replace("'", "") + "', '" +
                     oClass.Phone + "', '" +
                     oClass.Email.Replace("'", "") + "', '" +
                     oClass.CountryCode.Replace("'", "") + "', '" +
                     oClass.DateAccredit.ToString("yyyy-MM-d HH:MM:ss") + "', '" +
                     oClass.DateExpire.ToString("yyyy-MM-d HH:MM:ss") + "', '" +
                     currUser + "', " +
                     "CurDate(), '" +
                     currUser + "', " +
                     "CurDate() " +
                     ") ";

            SaveData(strSql);
        }
示例#2
0
        private void SaveData()
        {
            string sUserName = Session["User"].ToString();

            oDAL   = new InsuranceCompanyDAL();
            oClass = new InsuranceCompanyModel();


            oClass.Code          = Code.Value;
            oClass.CompanyName   = CompanyName.Value;
            oClass.ContactPerson = ContactPerson.Value;
            oClass.CountryCode   = ddlCountryCode.SelectedValue;
            oClass.Address       = txtAddress.InnerText;
            oClass.Phone         = txtContact.Value;
            oClass.Email         = txtEmail.Value;

            string id = ClientID.Value;

            if (id == "")
            {
                oDAL.InsertData(sUserName, oClass);
                //lblMsg.Text = "New Record has been saved";
            }
            else
            {
                oClass.ID = Convert.ToInt16(id);
                oDAL.UpdateData(sUserName, oClass);
                // lblMsg.Text = "Record has been updated";
            }
        }
        //获取投保保险公司
        public APIResponse GetInsuranceCompany(int userId)
        {
            var carInsuranceCompanys = (from u in CurrentDb.CarInsuranceCompany
                                        join r in CurrentDb.InsuranceCompany on u.InsuranceCompanyId equals r.Id
                                        where u.Status == Enumeration.CarInsuranceCompanyStatus.Normal
                                        select new { r.Id, r.Name, u.InsuranceCompanyImgUrl, u.Priority }).Distinct().OrderByDescending(m => m.Priority);


            InsuranceCompanyResult model = new InsuranceCompanyResult();

            model.CanInsureCount = 2;

            List <InsuranceCompanyModel> insuranceCompanyModels = new List <InsuranceCompanyModel>();

            foreach (var m in carInsuranceCompanys)
            {
                InsuranceCompanyModel insuranceCompanyModel = new InsuranceCompanyModel();
                insuranceCompanyModel.Id     = m.Id;
                insuranceCompanyModel.Name   = m.Name;
                insuranceCompanyModel.ImgUrl = m.InsuranceCompanyImgUrl;
                insuranceCompanyModels.Add(insuranceCompanyModel);
            }

            model.InsuranceCompany = insuranceCompanyModels;

            APIResult result = new APIResult()
            {
                Result = ResultType.Success, Code = ResultCode.Success, Message = "", Data = model
            };

            return(new APIResponse(result));
        }
        public DataSet SelectByID(InsuranceCompanyModel oClass)
        {
            strSql = "SELECT * " +
                     "FROM " + TABLE_NAME + " " +
                     "WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            return(Select(strSql));
        }
        public DataSet SelectByCountryCode(InsuranceCompanyModel oClass)
        {
            strSql = "SELECT A.*, B.Name as CountryName " +
                     "FROM " + TABLE_NAME + " A Left Outer Join Country B On A." + COLUMN_COUNTRY_CODE + " = B.Code " +
                     "WHERE A." + COLUMN_COUNTRY_CODE + " = '" + oClass.CountryCode + "' ";

            return(Select(strSql));
        }
示例#6
0
        public int Update(InsuranceCompanyModel model)
        {
            string sqlUpdate = "UPDATE InsuranceCompany SET Name = @Name, Email = @Email WHERE Id = @Id";

            using (_connection)
            {
                return(_connection.Execute(sqlUpdate, model));
            }
        }
示例#7
0
        public int Delete(InsuranceCompanyModel model)
        {
            string sqlDelete = "DELETE FROM InsuranceCompany WHERE Id = @Id";

            using (_connection)
            {
                return(_connection.Execute(sqlDelete, model));
            }
        }
示例#8
0
        public int Insert(InsuranceCompanyModel model)
        {
            string sqlInsert = "INSERT INTO InsuranceCompany (Id, Name, Email) " +
                               " Values (@Id, @Name, @Email)";

            using (_connection)
            {
                return(_connection.Execute(sqlInsert, model));
            }
        }
        public void DeleteData(string user, InsuranceCompanyModel oClass)
        {
            strSql = "UPDATE " + TABLE_NAME + " SET " +
                     " isDeleted = 1, " +
                     " ReasonDelete = '" + oClass.ReasonDelete.Replace("'", "''") + "', " +
                     " updated_by = '" + user + "', " +
                     " updated_date = '" + DateTime.Now.ToString("yyyy-MM-d HH:MM:ss") + "' " +
                     " WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            SaveData(strSql);
        }
        private void LoadInsuranceCompany()
        {
            InsuranceCompanyDAL   insuranceCompanyDAL = new InsuranceCompanyDAL();
            InsuranceCompanyModel insuranceModel      = new InsuranceCompanyModel();

            insuranceModel.CountryCode = "PHL";
            oDs = new DataSet();
            oDs = insuranceCompanyDAL.SelectByCountryCode(insuranceModel);
            //var result = oDs.Tables[0].AsEnumerable().Where(myRow => myRow.Field<string>("CountryCode") == "PHL").CopyToDataTable();
            ddlInsuranceCompany.DataSource     = oDs.Tables[0];
            ddlInsuranceCompany.DataTextField  = "CompanyName";
            ddlInsuranceCompany.DataValueField = "id";
            ddlInsuranceCompany.DataBind();
        }
示例#11
0
        protected void Ok_ServerClick(object sender, EventArgs e)
        {
            string UserName = Session["User"].ToString();
            int    ID       = Convert.ToInt32(HiddenFieldItem.Value);

            oDAL   = new InsuranceCompanyDAL();
            oClass = new InsuranceCompanyModel();
            oDs    = new DataSet();

            oClass.IsDeleted    = true;
            oClass.ReasonDelete = itemname.InnerText;
            string lbl = lblSelectedItem.Text;

            oClass.ID = ID;
            oDAL.DeleteData(UserName, oClass);
            PopulateGrid();
        }
        public void UpdateData(string user, InsuranceCompanyModel oClass)
        {
            strSql = "UPDATE " + TABLE_NAME + " SET " +
                     COLUMN_CODE + " = '" + oClass.Code + "', " +
                     COLUMN_COMPANY_NAME + " = '" + oClass.CompanyName.Replace("'", "") + "', " +
                     COLUMN_CONTACT_PERSON + " = '" + oClass.ContactPerson.Replace("'", "") + "', " +
                     COLUMN_ADDRESS + " = '" + oClass.Address.Replace("'", "") + "', " +
                     COLUMN_EMAIL + " = '" + oClass.Email.Replace("'", "") + "', " +
                     COLUMN_PHONE + " = '" + oClass.Phone + "', " +
                     COLUMN_COUNTRY_CODE + " = '" + oClass.CountryCode + "', " +
                     COLUMN_DATE_ACCREDIT + " = '" + oClass.DateAccredit.ToString("yyyy-MM-d HH:MM:ss") + "', " +
                     COLUMN_DATE_EXPIRE + " = '" + oClass.DateExpire.ToString("yyyy-MM-d HH:MM:ss") + "', " +
                     " updated_by = '" + user + "', " +
                     " updated_date = '" + DateTime.Now.ToString("yyyy-MM-d HH:MM:ss") + "' " +
                     " WHERE " + COLUMN_ID + " = '" + oClass.ID + "' ";

            SaveData(strSql);
        }
示例#13
0
        private void PopulateData(int id)
        {
            oDAL   = new InsuranceCompanyDAL();
            oClass = new InsuranceCompanyModel();
            oDs    = new DataSet();

            oClass.ID = id;

            oDs                          = oDAL.SelectByID(oClass);
            ClientID.Value               = oDs.Tables[0].Rows[0][0].ToString();
            Code.Value                   = oDs.Tables[0].Rows[0][1].ToString();
            CompanyName.Value            = oDs.Tables[0].Rows[0][2].ToString();
            ContactPerson.Value          = oDs.Tables[0].Rows[0][3].ToString();
            ddlCountryCode.SelectedValue = oDs.Tables[0].Rows[0][4].ToString();
            txtAddress.Value             = oDs.Tables[0].Rows[0][5].ToString();
            txtEmail.Value               = oDs.Tables[0].Rows[0][6].ToString();
            txtContact.Value             = oDs.Tables[0].Rows[0][7].ToString();
        }
示例#14
0
 /// <summary>
 /// Method whose purpose is to update
 /// a new InsuranceCompany record.
 /// </summary>
 /// <param name="insuranceCompany">
 /// Existing InsuranceCompanyModel object.
 /// </param>
 /// <returns>
 /// Returns true if the query is successfully executed
 /// otherwise returns false.
 /// </returns>
 public bool Update(InsuranceCompanyModel insuranceCompany)
 {
     return(_insuranceCompanyRepository.Update(insuranceCompany) > 0 ? true : false);
 }
示例#15
0
 /// <summary>
 /// Method whose purpose is to insert
 /// a new InsuranceCompany object.
 /// </summary>
 /// <param name="insuranceCompany">
 /// Existing InsuranceCompanyModel object.
 /// </param>
 /// <returns>
 /// Returns true if the query is successfully executed
 /// otherwise returns false.
 /// </returns>
 public bool Insert(InsuranceCompanyModel insuranceCompany)
 {
     return(_insuranceCompanyRepository.Insert(insuranceCompany) > 0 ? true : false);
 }