private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            DataGridItem item = this.DataGrid1.SelectedItem;

            if (this.txtCheckCount.Text.Trim() == "" || !this.JudgeIsNum(this.txtCheckCount.Text.Trim()))
            {
                this.Popup("盘点存量不能为空且必须是数字!");
                return;
            }

            StorageCheckLog scl = new StorageCheckLog();

            scl.cnvcDeptID    = this.ddlDept.SelectedValue;
            scl.cnvcWhCode    = this.ddlWhouse.SelectedValue;
            scl.cnvcInvCode   = item.Cells[0].Text.Trim();
            scl.cnnSysCount   = Math.Round(decimal.Parse(item.Cells[5].Text.Trim()), 2);
            scl.cnnCheckCount = Math.Round(decimal.Parse(this.txtCheckCount.Text.Trim()), 2);
            scl.cnvcUnitCode  = item.Cells[2].Text.Trim();
            scl.cnvcOperName  = this.oper.strOperName;
            scl.cnvcFlag      = "0";
            string strMdate   = "";
            string strExpdate = "";

            if (item.Cells[6].Text.Trim() != "")
            {
                scl.cndMdate = DateTime.Parse(item.Cells[6].Text.Trim());
                strMdate     = scl.cndMdate.Year.ToString();
                if (scl.cndMdate.Month < 10)
                {
                    strMdate += "0" + scl.cndMdate.Month.ToString();
                }
                else
                {
                    strMdate += scl.cndMdate.Month.ToString();
                }
                if (scl.cndMdate.Day < 10)
                {
                    strMdate += "0" + scl.cndMdate.Day.ToString();
                }
                else
                {
                    strMdate += scl.cndMdate.Day.ToString();
                }
            }
            if (item.Cells[7].Text.Trim() != "")
            {
                scl.cndExpDate = DateTime.Parse(item.Cells[7].Text.Trim());
                strExpdate     = scl.cndExpDate.Year.ToString();
                if (scl.cndExpDate.Month < 10)
                {
                    strExpdate += "0" + scl.cndExpDate.Month.ToString();
                }
                else
                {
                    strExpdate += scl.cndExpDate.Month.ToString();
                }
                if (scl.cndExpDate.Day < 10)
                {
                    strExpdate += "0" + scl.cndExpDate.Day.ToString();
                }
                else
                {
                    strExpdate += scl.cndExpDate.Day.ToString();
                }
            }
            string strcheckno = "";

            string strisexist = "";

            if (strMdate == "" && strExpdate == "")
            {
                strisexist = Helper.Query("select count(*) from tbStorageCheckLog where cnvcWhCode='" + scl.cnvcWhCode + "' and cnvcInvCode='" + scl.cnvcInvCode + "' and cnvcFlag='0' and cnvcCheckNo like convert(char(8),getdate(),112)+'%'").Rows[0][0].ToString();
            }
            else
            {
                strisexist = Helper.Query("select count(*) from tbStorageCheckLog where cnvcWhCode='" + scl.cnvcWhCode + "' and cnvcInvCode='" + scl.cnvcInvCode + "' and cnvcFlag='0' and cnvcCheckNo like convert(char(8),getdate(),112)+'%' and convert(char(8),cndMdate,112)='" + strMdate + "' and convert(char(8),cndExpDate,112)='" + strExpdate + "'").Rows[0][0].ToString();
            }
            if (strisexist != "0")
            {
                this.Popup("本仓库的" + item.Cells[1].Text.Trim() + "在今日内还有未确认的盘点记录,不可添加!");
                return;
            }
            else
            {
                StorageFacade sto = new StorageFacade();
                int           ret = sto.AddStorageCheckLog(scl, this.txtCheckNo.Text.Trim(), out strcheckno);
                if (ret > 0)
                {
                    this.Popup("添加盘点存货成功!");
                    this.ddlState.SelectedIndex = this.ddlState.Items.IndexOf(this.ddlState.Items.FindByValue("0"));
                    DataTable dtcheckno = Helper.Query("select distinct cnvcCheckNo as cnvcCode,cnvcCheckNo as cnvcName from tbStorageCheckLog where cnvcWhCode='" + this.ddlWhouse.SelectedValue + "' and cnvcCheckNo like '" + this.txtCheckNo.Text.Trim() + "%'");
                    this.FillDropDownList(dtcheckno, this.ddlDayCheckNo);
                    this.ddlDayCheckNo.SelectedIndex = this.ddlDayCheckNo.Items.IndexOf(this.ddlDayCheckNo.Items.FindByValue(strcheckno));
                    this.ddlDept.Enabled             = false;
                    this.ddlWhouse.Enabled           = false;
                    this.ddlDayCheckNo.Enabled       = false;
                    this.ddlState.Enabled            = false;
                    this.btnCheckOk.Enabled          = true;
                }
                else
                {
                    if (ret < 0)
                    {
                        this.Popup("该仓库在盘点序号“" + strcheckno + "”中已经有此存货的盘点记录,请重试!");
                    }
                    else
                    {
                        this.Popup("添加盘点存货失败!");
                    }
                }

                this.DataGrid1.DataSource = null;
                this.DataGrid1.DataBind();
                this.DBBind();
            }
        }