Exemple #1
0
 private void add_item(InsuranceAndReviewModel IARMODEL)
 {
     if (string.Compare(this.action, "Update", true) == 0)
     {
         IARMODEL.Guid = new Guid(this.hideIARGUID.Value);
     }
 }
Exemple #2
0
 private void initData()
 {
     if (this.IARGuid != "")
     {
         InsuranceAndReviewModel model = this.IARBLL.GetModel(new Guid(this.IARGuid));
         if (model != null)
         {
             this.hideIARGUID.Value = model.Guid.ToString();
             this.txtcode.Text      = model.code.ToString();
             this.txtcode.Enabled   = false;
             this.txtDate.Text      = model.Date.ToString().Substring(0, model.Date.ToString().LastIndexOf(" ") + 1);
             if (model.Type == 0)
             {
                 this.rado.Items[0].Selected = true;
             }
             else
             {
                 this.rado.Items[1].Selected = true;
             }
             if (model.VehicleCode.ToString() != "")
             {
                 this.hdnVehiclesCode.Value = model.VehicleCode.ToString();
                 if (this.BLL.Exists(new Guid(model.VehicleCode.ToString())))
                 {
                     this.txtVehicleCode.Text = this.BLL.GetModel(new Guid(model.VehicleCode.ToString())).VehicleCode;
                 }
             }
         }
     }
 }
        public List <InsuranceAndReviewModel> DataTableToList(DataTable dt)
        {
            List <InsuranceAndReviewModel> list = new List <InsuranceAndReviewModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    InsuranceAndReviewModel item = new InsuranceAndReviewModel();
                    if ((dt.Rows[i]["Guid"] != null) && (dt.Rows[i]["Guid"].ToString() != ""))
                    {
                        item.Guid = new Guid(dt.Rows[i]["Guid"].ToString());
                    }
                    if ((dt.Rows[i]["Date"] != null) && (dt.Rows[i]["Date"].ToString() != ""))
                    {
                        item.Date = dt.Rows[i]["Date"].ToString();
                    }
                    if ((dt.Rows[i]["Type"] != null) && (dt.Rows[i]["Type"].ToString() != ""))
                    {
                        item.Type = new int?(int.Parse(dt.Rows[i]["Type"].ToString()));
                    }
                    if ((dt.Rows[i]["VehicleCode"] != null) && (dt.Rows[i]["VehicleCode"].ToString() != ""))
                    {
                        item.VehicleCode = new Guid(dt.Rows[i]["VehicleCode"].ToString());
                    }
                    if ((dt.Rows[i]["code"] != null) && (dt.Rows[i]["code"].ToString() != ""))
                    {
                        item.code = dt.Rows[i]["code"].ToString();
                    }
                    list.Add(item);
                }
            }
            return(list);
        }
Exemple #4
0
 private void getModel(string guid)
 {
     if (guid != "")
     {
         InsuranceAndReviewModel model = this.IARBLL.GetModel(new Guid(guid));
         if (model != null)
         {
             this.hideIARGUID.Value = guid;
             this.txtcode.Text      = model.code;
             if (model.code != "")
             {
                 if (model.Type == 0)
                 {
                     this.rado.Items[0].Selected = true;
                 }
                 else
                 {
                     this.rado.Items[1].Selected = true;
                 }
             }
             this.txtDate.Text = ((model.Date == null) ? "" : DateTime.Parse(model.Date.ToString()).ToShortDateString());
             MainBLL mainBLL = new MainBLL();
             if (mainBLL.Exists(new Guid(model.VehicleCode.ToString())))
             {
                 this.Hidden_save_SID.Value = model.VehicleCode.ToString();
             }
         }
     }
 }
        public InsuranceAndReviewModel GetModel(Guid Guid)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select  top 1 Guid,Date,Type,VehicleCode,code from OA_Vehicle_InsuranceAndReview ");
            builder.Append(" where Guid=@Guid ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Guid", SqlDbType.UniqueIdentifier) };
            commandParameters[0].Value = Guid;
            InsuranceAndReviewModel model = new InsuranceAndReviewModel();
            DataTable table = SqlHelper.ExecuteQuery(CommandType.Text, builder.ToString(), commandParameters);

            if (table.Rows.Count <= 0)
            {
                return(null);
            }
            if (table.Rows[0]["Guid"].ToString() != "")
            {
                model.Guid = new Guid(table.Rows[0]["Guid"].ToString());
            }
            if (table.Rows[0]["Date"].ToString() != "")
            {
                model.Date = table.Rows[0]["Date"].ToString();
            }
            if (table.Rows[0]["Type"].ToString() != "")
            {
                model.Type = new int?(int.Parse(table.Rows[0]["Type"].ToString()));
            }
            if (table.Rows[0]["VehicleCode"].ToString() != "")
            {
                model.VehicleCode = new Guid(table.Rows[0]["VehicleCode"].ToString());
            }
            model.code = table.Rows[0]["code"].ToString();
            return(model);
        }
        public bool Update(InsuranceAndReviewModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_Vehicle_InsuranceAndReview set ");
            builder.Append("Date=@Date,");
            builder.Append("Type=@Type,");
            builder.Append("VehicleCode=@VehicleCode,");
            builder.Append("code=@code");
            builder.Append(" where Guid=@Guid ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Guid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@Date", SqlDbType.DateTime), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@VehicleCode", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@code", SqlDbType.NVarChar, 100) };
            commandParameters[0].Value = model.Guid;
            if ((model.Date.ToString() == "") || (model.Date == null))
            {
                commandParameters[1].Value = DBNull.Value;
            }
            else
            {
                commandParameters[1].Value = DateTime.Parse(model.Date);
            }
            commandParameters[2].Value = model.Type;
            commandParameters[3].Value = model.VehicleCode;
            commandParameters[4].Value = model.code;
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters) > 0);
        }
Exemple #7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        InsuranceAndReviewModel insuranceAndReviewModel = new InsuranceAndReviewModel();

        insuranceAndReviewModel.VehicleCode = new Guid(this.hdnVehiclesCode.Value);
        insuranceAndReviewModel.Type        = new int?(int.Parse(this.rado.SelectedValue));
        insuranceAndReviewModel.Date        = this.txtDate.Text.Trim().ToString();
        insuranceAndReviewModel.code        = this.txtcode.Text.ToString();
        insuranceAndReviewModel.Guid        = new Guid(this.hideIARGUID.Value.ToString());
        if (this.IARBLL.Update(insuranceAndReviewModel))
        {
            base.RegisterScript("top.ui.tabSuccess({ parentName: '_InsuranceAndReview' })");
        }
    }
        public void Add(InsuranceAndReviewModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_Vehicle_InsuranceAndReview(");
            builder.Append("Guid,Date,Type,VehicleCode,code)");
            builder.Append(" values (");
            builder.Append("@Guid,@Date,@Type,@VehicleCode,@code)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Guid", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@Date", SqlDbType.DateTime), new SqlParameter("@Type", SqlDbType.Int, 4), new SqlParameter("@VehicleCode", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@code", SqlDbType.NVarChar, 100) };
            commandParameters[0].Value = Guid.NewGuid();
            if ((model.Date.ToString() == "") || (model.Date == null))
            {
                commandParameters[1].Value = DBNull.Value;
            }
            else
            {
                commandParameters[1].Value = DateTime.Parse(model.Date);
            }
            commandParameters[2].Value = model.Type;
            commandParameters[3].Value = model.VehicleCode;
            commandParameters[4].Value = model.code;
            SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters);
        }
 public bool Update(InsuranceAndReviewModel model)
 {
     return(this.dal.Update(model));
 }
 public void Add(InsuranceAndReviewModel model)
 {
     this.dal.Add(model);
 }
Exemple #11
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        InsuranceAndReviewModel insuranceAndReviewModel = new InsuranceAndReviewModel();

        if (string.Compare(this.action, "Add", true) == 0)
        {
            try
            {
                if (this.hfldContract.Value.ToString() == "")
                {
                    base.RegisterScript("top.ui.alert('请选择车辆')");
                }
                else
                {
                    if (this.txtDate.Text.ToString().Trim() == "")
                    {
                        base.RegisterScript("top.ui.alert('请选择日期')");
                    }
                    else
                    {
                        List <string> list = new List <string>();
                        if (this.hfldContract.Value.Contains("["))
                        {
                            list = JsonHelper.GetListFromJson(this.hfldContract.Value);
                        }
                        else
                        {
                            list.Add(this.hfldContract.Value);
                        }
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list.Count > 1)
                            {
                                DateTime now = DateTime.Now;
                                insuranceAndReviewModel.code = now.ToString("yyyyMMdd") + now.Millisecond.ToString() + i.ToString();
                            }
                            else
                            {
                                insuranceAndReviewModel.code = this.txtcode.Text.ToString();
                            }
                            insuranceAndReviewModel.Date = this.txtDate.Text;
                            for (int j = 0; j < 2; j++)
                            {
                                if (this.rado.Items[j].Selected)
                                {
                                    insuranceAndReviewModel.Type = new int?(int.Parse(this.rado.SelectedValue.ToString()));
                                }
                            }
                            insuranceAndReviewModel.VehicleCode = new Guid(list[i].ToString());
                            this.IARBLL.Add(insuranceAndReviewModel);
                        }
                        base.RegisterScript("top.ui.tabSuccess({ parentName: '_InsuranceAndReview' })");
                    }
                }
            }
            catch (Exception)
            {
                base.RegisterScript("top.ui.alert('添加失败')");
            }
        }
    }