Exemple #1
0
        private void Query()
        {
            string strWhere = "";

            if (txt_Sdoc_No.Text.Trim() != string.Empty)//单据号
            {
                strWhere += string.Format(" AND a.S_Doc_NO='{0}'", txt_Sdoc_No.Text.Trim());
            }
            if (txt_MaterialCode.Text.Trim() != string.Empty)//料号
            {
                strWhere += string.Format(" AND b.MaterialCode = '{0}'", txt_MaterialCode.Text.Trim());
            }
            strWhere += string.Format(" AND a.Create_Time >=convert(datetime,'{0}')", dtp_CreateTimeMin.Text.Trim());
            strWhere += string.Format(" AND a.Create_Time <=convert(datetime,'{0}')", dtp_CreateTimeMax.Text.Trim());
            if (dgv_Detail.DataSource != null)//查询退料单据前先把物料SN信息删除
            {
                DataTable dt = (DataTable)dgv_Detail.DataSource;
                dt.Rows.Clear();
                dgv_Detail.DataSource = dt;
            }

            DataTable dtSDocMatr = Bll_Bllb_StorageDoc_tbsd.Query(strWhere);

            dgv_Material.DataSource = dtSDocMatr;
        }
Exemple #2
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_query_Click(object sender, EventArgs e)
        {
            string strWhere = " Where 1=1";

            if (txt_Sdoc_No.Text != string.Empty)//单据号
            {
                strWhere += string.Format(" AND SD.S_Doc_NO='{0}'", txt_Sdoc_No.Text.Trim());
            }
            if (cbo_MaterialCode.Text != string.Empty)//料号
            {
                strWhere += string.Format(" AND M.MaterialCode = '{0}'", cbo_MaterialCode.Text.Trim());
            }
            if (cbo_DocType.SelectedValue.ToString() != string.Empty)
            {
                strWhere += string.Format(" AND SD.S_Doc_Type='{0}'", cbo_DocType.SelectedValue.ToString());
            }
            else
            {
                DataTable dt  = (DataTable)S_Doc_Type.DataSource;
                string    str = string.Empty;
                foreach (DataRow dr in dt.Rows)
                {
                    str += str == string.Empty ? "'" + dr["DICT_CODE"].ToString() + "'" : ",'" + dr["DICT_CODE"].ToString() + "'";
                }
                strWhere += string.Format(" AND SD.S_Doc_Type in ({0})", str);
            }
            if (cmb_Line.SelectedValue.ToString() != string.Empty)//线别
            {
                strWhere += string.Format(" AND SD.PLCode='{0}'", cmb_Line.SelectedValue.ToString());
            }

            if (cbo_StorageSN.SelectedValue.ToString() != string.Empty)
            {
                strWhere += string.Format(" AND S.Storage_SN='{0}'", cbo_StorageSN.SelectedValue.ToString());
            }

            strWhere += string.Format(" AND SD.Create_Time >=convert(datetime,'{0}')", dtp_CreateTimeMin.Text.Trim());
            strWhere += string.Format(" AND SD.Create_Time <=convert(datetime,'{0}')", dtp_CreateTimeMax.Text.Trim());
            dtSDoc    = Bll_Bllb_StorageDoc_tbsd.Query(strWhere);
            dgv_SDoc_NO.DataSource = dtSDoc;
            dtSDoDetail.Clear();
            new PubUtils().ShowNoteOKMsg("查询成功!");
        }