注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Bioinformatics home

 
 
 

日志

 
 

GridView 套GridView 1  

2009-01-09 17:53:03|  分类: 编程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |


using BLL;
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
using yb.CtrlHelper;
using System.Linq;
using LinqHelper;
using  yb.SqlHelper;

 

public partial class _Project_ProjectStart: BasePage
    {


        private void Page_Load(object sender, EventArgs e)
        {

            if (!base.IsPostBack)
            {
                this.dpStartDate.Date = DateTime.Parse("0001-1-1 0:00:00");
                this.dpEndDate.Date = DateTime.Parse("0001-1-1 0:00:00");


            }
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            gvRow(GridView1);
           
            InitializeComponent();
        }
        private void InitializeComponent()
        {
           this.Imagebutton1.Click += new ImageClickEventHandler(this.bnSerach_Click);
           this.GridView1.PreRender += new EventHandler(GridView1_PreRender);
        }
        #endregion


        protected void GridView1_PreRender(object sender, EventArgs e)
        {

          //  yb.UtilityHelper.GridViewTool.MergeCells(GridView1, new int[] {1, 2, 3,  5,6,9 });
        }

 


        private void bnSerach_Click(object sender, ImageClickEventArgs e)
        {
            //this.WhereMethod();
            //if (this.tbcust.Text.Trim() != "")
            //{
            //    this.WhereStr = this.WhereStr + " and CustName like '%" + this.tbcust.Text + "%'";
            //}
            //if (this.tbContCoding.Text.Trim() != "")
            //{
            //    this.WhereStr = this.WhereStr + " and ContractNO like '%" + this.tbContCoding.Text + "%'";
            //}
            //if (this.tbContName.Text.Trim() != "")
            //{
            //    this.WhereStr = this.WhereStr + " and Title like '%" + this.tbContName.Text + "%'";
            //}
            //if (this.ddlDate.SelectedValue == "1")
            //{
            //    if ((this.dpStartDate.Date.ToString().Trim() != "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() != "0001-1-1 0:00:00"))
            //    {
            //        object yb22 = this.WhereStr;
            //        this.WhereStr = string.Concat(new object[] { yb22, " and StartDate>'", this.dpStartDate.Date, "' and StartDate<'", this.dpEndDate.Date, "'" });
            //    }
            //    else if ((this.dpStartDate.Date.ToString().Trim() != "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() == "0001-1-1 0:00:00"))
            //    {
            //        object yb26 = this.WhereStr;
            //        this.WhereStr = string.Concat(new object[] { yb26, " and StartDate>'", this.dpStartDate.Date, "'" });
            //    }
            //    else if ((this.dpStartDate.Date.ToString().Trim() == "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() != "0001-1-1 0:00:00"))
            //    {
            //        object yb210 = this.WhereStr;
            //        this.WhereStr = string.Concat(new object[] { yb210, " and StartDate<'", this.dpEndDate.Date, "'" });
            //    }
            //}
            //else if ((this.dpStartDate.Date.ToString().Trim() != "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() != "0001-1-1 0:00:00"))
            //{
            //    object yb214 = this.WhereStr;
            //    this.WhereStr = string.Concat(new object[] { yb214, " and EndDate>'", this.dpStartDate.Date, "' and EndDate<'", this.dpEndDate.Date, "'" });
            //}
            //else if ((this.dpStartDate.Date.ToString().Trim() != "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() == "0001-1-1 0:00:00"))
            //{
            //    object yb218 = this.WhereStr;
            //    this.WhereStr = string.Concat(new object[] { yb218, " and EndDate>'", this.dpStartDate.Date, "'" });
            //}
            //else if ((this.dpStartDate.Date.ToString().Trim() == "0001-1-1 0:00:00") && (this.dpEndDate.Date.ToString().Trim() != "0001-1-1 0:00:00"))
            //{
            //    object yb212 = this.WhereStr;
            //    this.WhereStr = string.Concat(new object[] { yb212, " and EndDate<'", this.dpEndDate.Date, "'" });
            //}
            //this.ViewState["WhereStr"] = this.WhereStr;
            //this.ContBind();
        }

 

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            string sql = "";
          //  View1.DataKeys[e.Row.RowIndex].Values["Mode"].ToString().ToLower() == "false")
            //把客户提供原材料状态显示
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                        if (Convert.ToInt32(e.Row.Cells[12].Text) > 0)
                        {             
                            string projectID = e.Row.Cells[17].Text.Trim();
                            sql = "select * FROM _X_客户提供原材料 where _项目号='" + projectID + "' ";
                            GridView gridView2 = (GridView)e.Row.Cells[10].FindControl("GridView2");
                         //   e.Row.Cells[10].BackColor
                            gridView2.Attributes.Add("BackColor", e.Row.Cells[9].BackColor.ToString());
                            gridView2.Attributes.Add("BorderColor", e.Row.Cells[9].BackColor.ToString());
                            gridView2.Attributes.Add("BorderColor", e.Row.Cells[9].BackColor.ToString());
                            DataSet ds = yb.SqlHelper.DBClass.dataSetQuery(sql);
                            gridView2.DataSource = ds;
                            gridView2.DataBind();
                        }

                e.Row.Cells[13].Text = Erp.PageTool._InvoiceState(e.Row.Cells[13].Text);

                e.Row.Cells[15].Text = Erp.PageTool._MoneyState(e.Row.Cells[15].Text);           


            }

        }


        protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
              //  e.Row.Cells[3].Text = Erp.PageTool._MaterialState(e.Row.Cells[1].Text.Trim());
            }
        }
   

 

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
         
               string ID = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
               string Situation = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("_原材料状态")).SelectedValue.ToString();
               string sql = "";
           
        }

 

        protected void GridView1_RowUpdating1(object sender, GridViewUpdateEventArgs e)
        {
            string ID = GridView1.DataKeys[e.RowIndex].Values[0].ToString();

            string Situation = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("_状态")).SelectedValue.ToString();
            string sql = "";
           

            if (Situation.Trim() != "")
            {
                if (Situation == "7")
                {
                    sql = "update _P_项目表 set _XM项目状态=7,_XM账款状态=2,  _XM项目起始日=getdate() where _XM项目表ID=" + ID;
                }
                else
                {


                    sql = "update _P_项目表 set _XM项目状态=" + Situation + " where _XM项目表ID=" + ID;
                }

                //yb.WebHelper.ShowMessage.AjaxShow("状态更新成功!");
                //GridView1.DataBind();

                try
                {
                    //Database.SQLOperation(sql);
                    //GridView1.DataBind();
                    SqlDataSource1.UpdateCommand = sql;
                    SqlDataSource1.Update();
                    GridView1.DataBind();

                    yb.WebHelper.ShowMessage.AjaxShow("状态更新成功!");
                }
                catch
                {
                    yb.WebHelper.ShowMessage.AjaxShow("状态未更新!");
                }
            }

        }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {

          


        }

        protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
           
            if (e.CommandName == "Edit1")
            {
                string sql="";
                  int index = Convert.ToInt32(e.CommandArgument);
                    GridView sender2=sender as GridView;
                 string selectValue = ((DropDownList)sender2.Rows[index].FindControl("_原材料状态")).SelectedItem.Value;
                 string MaterialID = sender2.DataKeys[index].Values["_客户提供原材料ID"].ToString();
                switch (selectValue)
                {
                    case "1":
                        sql="update _X_客户提供原材料 set _Y原材料状态=1   where _客户提供原材料ID="+MaterialID;
                        break;
                    case "2":
                        sql = "update _X_客户提供原材料 set _Y原材料状态=2 ,_QC=0, _QC日期=null,_收到日期=getdate() where _客户提供原材料ID=" + MaterialID;
                        break;
                    case "3":
                        sql = "update _X_客户提供原材料 set _Y原材料状态=3,_QC=1, _QC日期=getdate(), _QC是否通过=1  where _客户提供原材料ID=" + MaterialID;
                        break;
                    case "4":
                        sql = "update _X_客户提供原材料 set _Y原材料状态=4,_QC=1,  _QC日期=getdate(), _QC是否通过=0   where _客户提供原材料ID=" + MaterialID;
                        break;
                    default:
                        sql = "";
                        yb.WebHelper.ShowMessage.AjaxShow("更新失败!");
                        return;
                        break;
                      
                }
                yb.SqlHelper.DBClass.SQLOperation(sql);
              //  yb.SqlHelper.Database.SQLOperation(sql);
                yb.WebHelper.ShowMessage.AjaxShow("更新成功!");
                this.GridView1.DataBind();

               

            }


        }
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }

        protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
        {
          
        }

        protected void gridview2_Click(object sender, GridViewRowEventArgs e)
        {
         
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string str = yb.UtilityHelper.GridViewTool.GetCheckedDataKey(this.GridView1, 0);
            string sql = "";
            if (this.MaterialName.Text.Trim() == "")
            {
                yb.WebHelper.ShowMessage.AjaxShow("材料名称不为空!");
                this.MaterialName.Focus();
            }


            if (str != "")
            {
                using (var db = dbLinq.GetErpData())
                {

                    string[] f = str.Split(new char[] { ',' });
                    foreach (var _f in f)
                    {
                        //更新QC状态
                        sql = " insert  into _X_客户提供原材料(_项目号,_原材料名称,_原材料类型,_接收说明) select _XM项目ID, '"+ this.MaterialName.Text.Trim()+"', '"+this.MaterialType.SelectedValue.Trim()+"','"+this.MaterialMemo.Text.Trim()+"' from _P_项目表 where _XM项目表ID=" + _f;
                       db.ExecuteCommand(sql);
                       sql = "update  _P_项目表 set _XM原材料数量=_XM原材料数量+1 where _XM项目表ID="+_f;
                       db.ExecuteCommand(sql);

                    }

                    this.GridView1.DataBind();
                    yb.WebHelper.ShowMessage.AjaxShow("成功增加原材!");
                }
            }
            else
            {
                yb.WebHelper.ShowMessage.AjaxShow("未选择任何项目");
            }

 

        }
}


 

  评论这张
 
阅读(759)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017