Exemplo n.º 1
0
    public void Delete(int pf_id)
    {
        ProductTempFormatInfo        info  = GettempKey(pf_id);
        List <ProductTempFormatInfo> infos = UpdateSortingWithCategory(info.pc_id, info.pf_sorting);

        foreach (ProductTempFormatInfo pdtfm in infos)
        {
            db.Update(pdtfm.pc_id, pdtfm.pf_name, pdtfm.pf_value, pdtfm.pf_sorting - 1, pdtfm.pf_id);
        }
        db.Delete(pf_id);
    }
Exemplo n.º 2
0
    public List <ProductTempFormatInfo> UpdateSortingWithCategory(int pc_id, int sorting)
    {
        List <ProductTempFormatInfo> infos = new List <ProductTempFormatInfo>();
        IDataReader reader = db.UpdateSorting(pc_id, sorting).CreateDataReader();

        while (reader.Read())
        {
            infos.Add(ProductTempFormatInfo.Populate(reader));
        }
        return(infos);
    }
Exemplo n.º 3
0
    public ProductTempFormatInfo GettempKey(int pf_id)
    {
        ProductTempFormatInfo info   = new ProductTempFormatInfo();
        IDataReader           reader = db.GetTempKey(pf_id).CreateDataReader();

        while (reader.Read())
        {
            info = ProductTempFormatInfo.Populate(reader);
        }
        return(info);
    }
Exemplo n.º 4
0
    public List <ProductTempFormatInfo> GetallWithCategory(int pc_id)
    {
        List <ProductTempFormatInfo> infos = new List <ProductTempFormatInfo>();
        IDataReader reader = db.GetDataByCategory(pc_id).CreateDataReader();

        while (reader.Read())
        {
            infos.Add(ProductTempFormatInfo.Populate(reader));
        }
        return(infos);
    }
Exemplo n.º 5
0
    public int GetCategorySortingDesc(int pc_id)
    {
        ProductTempFormatInfo info   = new ProductTempFormatInfo();
        IDataReader           reader = db.GetCategorySortingDESC(pc_id).CreateDataReader();

        if (reader.Read())
        {
            info = ProductTempFormatInfo.Populate(reader);
            return(info.pf_sorting + 1);
        }
        return(1);
    }
Exemplo n.º 6
0
    protected void btNewFormat_Click(object sender, EventArgs e)
    {
        if (txtNewFormat.Text == "")
        {
            //this.Page.Controls.Add(Tools.Tomsg("請輸入規格名稱"));
            ShowMessage("請輸入規格名稱");
            return;
        }
        ProductTempFormatInfo info = new ProductTempFormatInfo();

        info.pc_id      = Tools.TryParseMethod(ddlCategory.SelectedValue);
        info.pf_name    = txtNewFormat.Text;
        info.pf_sorting = pdtFMBLL.GetCategorySortingDesc(info.pc_id);
        //寫入TempFormat 名稱、排序、類別
        pdtFMBLL.Insert(info);
        //再提出給予Repeater
        rpFormat.DataSource = pdtFMBLL.GetallWithCategory(info.pc_id);
        rpFormat.DataBind();
    }
Exemplo n.º 7
0
 //儲存更新
 protected void btSave_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < rpFormat.Items.Count; i++)
     {
         Label   lbformatID         = (Label)rpFormat.Items[i].FindControl("lbFormatID");
         Label   lbformat           = (Label)rpFormat.Items[i].FindControl("lbFormat");
         TextBox txtFormatValue     = (TextBox)rpFormat.Items[i].FindControl("txtFormatValue");
         TextBox txtSorting         = (TextBox)rpFormat.Items[i].FindControl("txtSorting");
         ProductTempFormatInfo info = new ProductTempFormatInfo();
         info.pf_id      = Tools.TryParseMethod(lbformatID.Text);
         info.pc_id      = Tools.TryParseMethod(ddlCategory.SelectedValue);
         info.pf_name    = lbformat.Text;
         info.pf_value   = txtFormatValue.Text;
         info.pf_sorting = Tools.TryParseMethod(txtSorting.Text); //必須驗證
         pdtFMBLL.Update(info);
         ShowMessage("儲存規格成功");
     }
     rpFormat.DataSource = pdtFMBLL.GetallWithCategory(Tools.TryParseMethod(ddlCategory.SelectedValue));
     rpFormat.DataBind();
 }
Exemplo n.º 8
0
 public void Update(ProductTempFormatInfo info)
 {
     db.Update(info.pc_id, info.pf_name, info.pf_value, info.pf_sorting, info.pf_id);
 }
Exemplo n.º 9
0
 public void Insert(ProductTempFormatInfo info)
 {
     info.pf_sorting = GetCategorySortingDesc(info.pc_id);
     db.Insert(info.pc_id, info.pf_name, info.pf_value, info.pf_sorting);
 }
Exemplo n.º 10
0
    //repeater刪除規格事件
    //動態上下排序事件寫於此
    protected void rpFormat_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        Label lb = (Label)e.Item.FindControl("lbFormatID");
        Label lb2;
        Label lb3;
        int   ClickNowKey   = 0;
        int   RdyChangeKey  = 0;
        int   ClickNowSort  = 0;
        int   RdyChangeSort = 0;

        if (e.CommandName == "Delete")
        {
            pdtFMBLL.Delete(int.Parse(lb.Text));
        }
        if (e.CommandName == "btnSortUp")
        {
            ClickNowKey  = e.Item.ItemIndex;
            RdyChangeKey = e.Item.ItemIndex - 1;
            if (ClickNowKey > 0)
            {
                lb2 = (Label)rpFormat.Items[ClickNowKey].FindControl("lbFormatID");
                lb3 = (Label)rpFormat.Items[RdyChangeKey].FindControl("lbFormatID");
                ProductTempFormatInfo pdTFMClick  = pdtFMBLL.GettempKey(int.Parse(lb2.Text));
                ProductTempFormatInfo pdTFMChange = pdtFMBLL.GettempKey(int.Parse(lb3.Text));
                ClickNowSort           = pdTFMClick.pf_sorting;
                RdyChangeSort          = pdTFMChange.pf_sorting;
                pdTFMClick.pf_sorting  = RdyChangeSort;
                pdTFMChange.pf_sorting = ClickNowSort;
                pdtFMBLL.Update(pdTFMClick);
                pdtFMBLL.Update(pdTFMChange);
            }
            else
            {
                ShowMessage("此項目排序已是第一位");
            }
        }
        if (e.CommandName == "btnSortDown")
        {
            ClickNowKey  = e.Item.ItemIndex;
            RdyChangeKey = e.Item.ItemIndex + 1;
            if (ClickNowKey + 1 < rpFormat.Items.Count) //底部判斷錯誤
            {
                lb2 = (Label)rpFormat.Items[ClickNowKey].FindControl("lbFormatID");
                lb3 = (Label)rpFormat.Items[RdyChangeKey].FindControl("lbFormatID");
                ProductTempFormatInfo pdTFMClick  = pdtFMBLL.GettempKey(int.Parse(lb2.Text));
                ProductTempFormatInfo pdTFMChange = pdtFMBLL.GettempKey(int.Parse(lb3.Text));
                ClickNowSort           = pdTFMClick.pf_sorting;
                RdyChangeSort          = pdTFMChange.pf_sorting;
                pdTFMClick.pf_sorting  = RdyChangeSort;
                pdTFMChange.pf_sorting = ClickNowSort;
                pdtFMBLL.Update(pdTFMClick);
                pdtFMBLL.Update(pdTFMChange);
            }
            else
            {
                ShowMessage("此項目排序已是最底");
            }
        }
        rpFormat.DataSource = pdtFMBLL.GetallWithCategory(Tools.TryParseMethod(ddlCategory.SelectedValue));
        rpFormat.DataBind();
    }