Esempio n. 1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.YZT_CMerchants model)
 {
     return(dal.Update(model));
 }
Esempio n. 2
0
    /// <summary>
    /// 新增招商信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Hi.Model.YZT_CMerchants cmModel = null;

        string [] ProvideData = new string[4];
        if (this.chk1.Checked)
        {
            ProvideData[0] = "1";
        }
        if (this.chk2.Checked)
        {
            ProvideData[1] = "2";
        }
        if (this.chk3.Checked)
        {
            ProvideData[2] = "3";
        }
        if (this.chk4.Checked)
        {
            ProvideData[3] = "4";
        }

        if (KeyID != 0)
        {
            cmModel = new Hi.BLL.YZT_CMerchants().GetModel(this.KeyID);

            SqlTransaction Tran = null;
            try
            {
                Tran = DBUtility.SqlHelper.CreateStoreTranSaction();

                if ("2".Equals(cmModel.Type.ToString()))
                {
                    if (!new Hi.BLL.YZT_FCArea().CMDelete(this.KeyID, Tran))
                    {
                        //Tran.Rollback();
                        //return;
                    }
                }
                else if ("3".Equals(cmModel.Type.ToString()))
                {
                    if (!new Hi.BLL.YZT_FCDis().CMDelete(this.KeyID, Tran))
                    {
                        //Tran.Rollback();
                        //return;
                    }
                }

                //cmModel.CMCode = this.txtCMCode.Value.Trim();
                cmModel.CMName = this.txtCMName.Value.Trim();

                cmModel.GoodsID     = this.hidGoodsID.Value.ToInt(0);
                cmModel.GoodsCode   = this.txtGoodsCode.Value.Trim();
                cmModel.GoodsName   = this.txtGoodsName.Value.Trim();
                cmModel.Remark      = this.OrderNote.Value.Trim();
                cmModel.ValueInfo   = this.txtValueInfo.Value.Trim();
                cmModel.InvalidDate = this.txtInvalidDate.Value != "" ? Convert.ToDateTime(this.txtInvalidDate.Value.Trim()) : DateTime.MinValue;
                cmModel.ForceDate   = this.txtForceDate.Value != "" ? Convert.ToDateTime(this.txtForceDate.Value.Trim()) : DateTime.MinValue;
                cmModel.ProvideData = string.Join(",", ProvideData);
                cmModel.CategoryID  = this.hidCategoryID.Value.Trim().ToInt(0);
                cmModel.Type        = ddrtype.Value.ToString().ToInt(0);
                cmModel.IsEnabled   = 0;
                cmModel.ts          = DateTime.Now;
                cmModel.modifyuser  = this.UserID;

                string fc = this.hidfc.Value;
                if (new Hi.BLL.YZT_CMerchants().Update(cmModel, Tran))
                {
                    if (!"".Equals(fc))
                    {
                        string[] fcval = fc.Split(new char[] { ',' });
                        if (ddrtype.Value.ToString() == "2")
                        {
                            //指定区域
                            Hi.Model.YZT_FCArea areaModel = null;
                            foreach (var item in fcval)
                            {
                                string[] fcvals = item.ToString().Split(new char[] { '|' });

                                areaModel = new Hi.Model.YZT_FCArea();
                                //areaModel.AreaID = item.ToInt(0);
                                areaModel.Province = fcvals[0] + "";
                                areaModel.City     = fcvals[1] + "";
                                areaModel.Area     = fcvals[2] + "";

                                areaModel.CMID         = this.KeyID;
                                areaModel.CompID       = this.CompID;
                                areaModel.ts           = DateTime.Now;
                                areaModel.CreateDate   = DateTime.Now;
                                areaModel.CreateUserID = this.UserID;
                                areaModel.modifyuser   = this.UserID;
                                new Hi.BLL.YZT_FCArea().Add(areaModel, Tran);
                            }
                        }
                        else if (ddrtype.Value.ToString() == "3")
                        {
                            //指定代理商
                            Hi.Model.YZT_FCDis fcdisModel = null;
                            foreach (var item in fcval)
                            {
                                fcdisModel        = new Hi.Model.YZT_FCDis();
                                fcdisModel.DisID  = item.ToInt(0);
                                fcdisModel.CMID   = this.KeyID;
                                fcdisModel.CompID = this.CompID;

                                fcdisModel.ts           = DateTime.Now;
                                fcdisModel.CreateDate   = DateTime.Now;
                                fcdisModel.CreateUserID = this.UserID;
                                fcdisModel.modifyuser   = this.UserID;

                                new Hi.BLL.YZT_FCDis().Add(fcdisModel, Tran);
                            }
                        }
                    }
                    Tran.Commit();
                    Response.Redirect("CMerchantsInfo.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey));
                }
                else
                {
                    Tran.Rollback();
                }
            }
            catch (Exception)
            {
                //Tran.Rollback();
                throw;
            }
        }
        else
        {
            cmModel = new Hi.Model.YZT_CMerchants();

            cmModel.CompID = this.CompID;
            cmModel.CMCode = GetNo(); //this.txtCMCode.Value.Trim();
            cmModel.CMName = this.txtCMName.Value.Trim();

            cmModel.GoodsCode    = this.txtGoodsCode.Value.Trim();
            cmModel.GoodsName    = this.txtGoodsName.Value.Trim();
            cmModel.Remark       = this.OrderNote.Value.Trim();
            cmModel.ValueInfo    = this.txtValueInfo.Value.Trim();
            cmModel.InvalidDate  = this.txtInvalidDate.Value != "" ? Convert.ToDateTime(this.txtInvalidDate.Value.Trim()) : DateTime.MinValue;
            cmModel.ForceDate    = this.txtForceDate.Value != "" ? Convert.ToDateTime(this.txtForceDate.Value.Trim()) : DateTime.MinValue;
            cmModel.ProvideData  = string.Join(",", ProvideData);
            cmModel.CategoryID   = this.txtCategoryID.Value.Trim().ToInt(0);
            cmModel.Type         = ddrtype.Value.ToString().ToInt(0);
            cmModel.IsEnabled    = 0;
            cmModel.GoodsID      = this.hidGoodsID.Value.ToInt(0);
            cmModel.ts           = DateTime.Now;
            cmModel.CreateDate   = DateTime.Now;
            cmModel.CreateUserID = this.UserID;
            cmModel.modifyuser   = this.UserID;

            string fc = this.hidfc.Value;

            SqlTransaction Tran = null;
            try
            {
                Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
                int id = new Hi.BLL.YZT_CMerchants().Add(cmModel, Tran);
                if (id > 0)
                {
                    if (!"".Equals(fc))
                    {
                        string[] fcval = fc.Split(new char[] { ',' });
                        if (ddrtype.Value.ToString() == "2")
                        {
                            //指定区域
                            Hi.Model.YZT_FCArea areaModel = null;
                            foreach (var item in fcval)
                            {
                                string[] fcvals = item.ToString().Split(new char[] { '|' });
                                areaModel = new Hi.Model.YZT_FCArea();
                                //areaModel.AreaID = item.ToInt(0);
                                areaModel.Province     = fcvals[0] + "";
                                areaModel.City         = fcvals[1] + "";
                                areaModel.Area         = fcvals[2] + "";
                                areaModel.CMID         = id;
                                areaModel.CompID       = this.CompID;
                                areaModel.ts           = DateTime.Now;
                                areaModel.CreateDate   = DateTime.Now;
                                areaModel.CreateUserID = this.UserID;
                                areaModel.modifyuser   = this.UserID;
                                new Hi.BLL.YZT_FCArea().Add(areaModel, Tran);
                            }
                        }
                        else if (ddrtype.Value.ToString() == "3")
                        {
                            //指定代理商

                            Hi.Model.YZT_FCDis fcdisModel = null;
                            foreach (var item in fcval)
                            {
                                fcdisModel        = new Hi.Model.YZT_FCDis();
                                fcdisModel.DisID  = item.ToInt(0);
                                fcdisModel.CMID   = id;
                                fcdisModel.CompID = this.CompID;

                                fcdisModel.ts           = DateTime.Now;
                                fcdisModel.CreateDate   = DateTime.Now;
                                fcdisModel.CreateUserID = this.UserID;
                                fcdisModel.modifyuser   = this.UserID;

                                new Hi.BLL.YZT_FCDis().Add(fcdisModel, Tran);
                            }
                        }
                    }

                    Tran.Commit();
                    Response.Redirect("CMerchantsInfo.aspx?KeyID=" + Common.DesEncrypt(id.ToString(), Common.EncryptKey));
                }
                else
                {
                    Tran.Rollback();
                }
            }
            catch (Exception)
            {
                //Tran.Rollback();
                throw;
            }
        }
    }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.YZT_CMerchants model)
 {
     return(dal.Add(model));
 }