Exemplo n.º 1
0
 public void BindData()
 {
     DBOperation.DBOperationManagment dbm = new DBOperation.DBOperationManagment();
     try
     {
         if (view_action == "notify")
         {
             Model.ProductCenter cp = Factory.GetExecution().SelectByID <Model.ProductCenter>(requestID);
             if (cp != null)
             {
                 if (cp.Language == 1)
                 {
                     Chinese.Checked = true;
                 }
                 else if (cp.Language == 3)
                 {
                     English.Checked = true;
                 }
                 else if (cp.Language == 2)
                 {
                     Traditional.Checked = true;
                 }
                 txtTitle.Text               = cp.ProductTitle;
                 txtCreatePeople.Text        = cp.CreatePeople;
                 HomePageUploadImg.ImageUrl  = WebSite.IMAGESERVER_WEBPATH + photoPath + cp.LogoUrl;
                 HomePageUploadFileName.Text = cp.LogoUrl;
                 txtKeywords.Text            = cp.Keywords;
                 txtDescription.Text         = cp.Description;
                 Model.ProductCenterModel[] pcList = DAL.GetDataTable.GetProductModel(cp.ProductID, dbm);
                 foreach (var item in pcList)
                 {
                     string html = hfEditHtml.Value;
                     if (!string.IsNullOrEmpty(html))
                     {
                         hfEditHtml.Value = html + "," + item.ProductModel + ":" + item.ID;
                     }
                     else
                     {
                         hfEditHtml.Value = item.ProductModel + ":" + item.ID;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Common.MessageBox.ShowLayer(this, ex.Message, 2);
     }
 }
Exemplo n.º 2
0
        protected void rptSpec_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            DBOperation.DBOperationManagment dbm = new DBOperation.DBOperationManagment();
            string msg = string.Empty;

            try
            {
                dbm.Open();
                switch (e.CommandName)
                {
                case "Delete":
                    try
                    {
                        string IDValue = e.CommandArgument.ToString();
                        int    ID      = 0;
                        if (Int32.TryParse(IDValue, out ID))
                        {
                            Model.ProductCenter pc = Factory.GetExecution().SelectByID <Model.ProductCenter>(ID);
                            if (pc != null && Factory.GetExecution().Delete <Model.ProductCenter>(ID))
                            {
                                if (DAL.GetDataTable.Delete <Model.ProductCenterModel>(pc.ProductID))
                                {
                                    Common.MessageBox.ShowLayer(this, "删除成功!", 1);
                                    BindData();
                                }
                                else
                                {
                                    Common.MessageBox.ShowLayer(this, "删除失败!", 2);
                                    return;
                                }
                            }
                            else
                            {
                                Common.MessageBox.ShowLayer(this, "删除失败!", 2);
                                return;
                            }
                        }
                        else
                        {
                            Common.MessageBox.ShowLayer(this, "请求参数错误!", 2);
                        }
                    }
                    catch
                    {
                        Common.MessageBox.ShowLayer(this, "删除失败!", 2);
                    }
                    finally
                    {
                        dbm.Close();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Common.MessageBox.ShowLayer(this, "数据处理失败!" + ex.ToString(), 2);
            }
            finally
            {
                dbm.Close();
            }
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int ProductType = Convert.ToInt32(Request["ProductType"]);
            int Language    = Convert.ToInt32(Request.Form["language"]);

            DBOperation.DBOperationManagment dbm = new DBOperation.DBOperationManagment();
            try
            {
                dbm.Open();
                if (view_action == "notify")
                {
                    Model.ProductCenter cp = Factory.GetExecution().SelectByID <Model.ProductCenter>(requestID);
                    if (cp != null)
                    {
                        List <Model.ProductCenter> pcList = Factory.GetExecution().GetByWhereSqlList <Model.ProductCenter>(" and ProductType=" + ProductType + " and Language=" + Language, " UpdateTime desc");
                        if (pcList != null && pcList.Count > 0 && cp.Language != Language)
                        {
                            Common.MessageBox.ShowLayer(this, "同一种语言只能新建一个产品分类!", 2);
                            return;
                        }
                        cp.Language     = Language;
                        cp.ProductTitle = txtTitle.Text;
                        cp.CreatePeople = txtCreatePeople.Text;
                        cp.LogoUrl      = HomePageUploadFileName.Text;
                        cp.CreatePeople = txtCreatePeople.Text;
                        cp.UpdateTime   = DateTime.Now;
                        cp.Keywords     = txtKeywords.Text.Trim();
                        cp.Description  = txtDescription.Text.Trim();
                        bool flag2 = true;
                        //flag2 = DAL.GetDataTable.Delete<Model.ProductCenterModel>(cp.ProductID);

                        if (!string.IsNullOrEmpty(hfArrList.Value))
                        {
                            List <Prm> list = JsonConvert.DeserializeObject <List <Prm> >(hfArrList.Value);
                            foreach (Prm item in list)
                            {
                                if (!string.IsNullOrEmpty(item.ProductModel))
                                {
                                    DataTable dt = DAL.GetDataTable.IsExistProductModel(item.ProductModel, cp.ProductID, dbm);
                                    if (dt != null && dt.Rows.Count > 0)
                                    {
                                    }
                                    else
                                    {
                                        Model.ProductCenterModel pcm = new Model.ProductCenterModel();
                                        pcm.ProductModelID = RuleUtility.IDsCreater.GetCreater().CreateProductModelID(dbm);
                                        pcm.Language       = Language;
                                        pcm.ProductID      = cp.ProductID;
                                        pcm.ProductModel   = item.ProductModel;
                                        pcm.CreateTime     = DateTime.Now;
                                        pcm.UpdateTime     = DateTime.Now;
                                        flag2 = Factory.GetExecution().Add <Model.ProductCenterModel>(pcm);
                                    }
                                }
                            }
                        }
                        bool flag = Factory.GetExecution().Update <Model.ProductCenter>(cp);
                        if (flag && flag2)
                        {
                            Common.MessageBox.ShowRedirect(this, "/ProductCenter/ServoDriver.aspx?ProductType=" + ProductType);
                        }
                    }
                }
                else
                {
                    List <Model.ProductCenter> pcList = Factory.GetExecution().GetByWhereSqlList <Model.ProductCenter>(" and ProductType=" + ProductType + " and Language=" + Language, " UpdateTime desc");
                    if (pcList != null && pcList.Count > 0)
                    {
                        Common.MessageBox.ShowLayer(this, "同一种语言只能新建一个产品分类!", 2);
                        return;
                    }
                    Model.ProductCenter cp = new Model.ProductCenter();
                    cp.ProductID    = RuleUtility.IDsCreater.GetCreater().CreateProductID(dbm);
                    cp.Language     = Language;
                    cp.ProductType  = ProductType;
                    cp.ProductTitle = txtTitle.Text;
                    cp.CreatePeople = txtCreatePeople.Text;
                    cp.LogoUrl      = HomePageUploadFileName.Text;
                    cp.CreatePeople = txtCreatePeople.Text;
                    cp.UpdateTime   = DateTime.Now;
                    cp.CreateTime   = DateTime.Now;
                    cp.Keywords     = txtKeywords.Text.Trim();
                    cp.Description  = txtDescription.Text.Trim();
                    bool flag1 = Factory.GetExecution().Add <Model.ProductCenter>(cp);
                    bool flag2 = true;
                    if (!string.IsNullOrEmpty(hfArrList.Value))
                    {
                        List <Prm> list = JsonConvert.DeserializeObject <List <Prm> >(hfArrList.Value);
                        foreach (Prm item in list)
                        {
                            if (!string.IsNullOrEmpty(item.ProductModel))
                            {
                                Model.ProductCenterModel pcm = new Model.ProductCenterModel();
                                pcm.ProductModelID = RuleUtility.IDsCreater.GetCreater().CreateProductModelID(dbm);
                                pcm.Language       = Language;
                                pcm.ProductID      = cp.ProductID;
                                pcm.ProductModel   = item.ProductModel;
                                pcm.CreateTime     = DateTime.Now;
                                pcm.UpdateTime     = DateTime.Now;
                                flag2 = Factory.GetExecution().Add <Model.ProductCenterModel>(pcm);
                            }
                        }
                    }
                    if (flag1 && flag2)
                    {
                        Common.MessageBox.ShowRedirect(this, "/ProductCenter/ServoDriver.aspx?ProductType=" + ProductType);
                    }
                }
            }
            catch (Exception ex)
            {
                Common.MessageBox.ShowLayer(this, "添加失败!" + ex.Message, 2);
            }
            finally
            {
                dbm.Close();
                BindData();
            }
        }