Exemplo n.º 1
0
        /// <summary>
        /// 初始化 单据子表
        /// </summary>
        private void InitDataGridViewDetail(string ReceiptId, string receiptTypeID)
        {
            if (receiptTypeID == "")
            {
                return;
            }

            SortedList <int, string> listReceDetailItems;//单据子表项

            listReceDetailItems = ReceiptModalCfgDAO.GetShowItems(receiptTypeID, 1, -1);

            //构造Sql
            string strSql = "select ";
            string fileds = "";

            if (listReceDetailItems != null)
            {
                foreach (string str in listReceDetailItems.Values)
                {
                    string filedTemp = ReceiptModCfg.GetReceiptDetailItems()[str.Trim()].Trim();
                    fileds += filedTemp.Substring(2) + " as " + str + ",";
                }
            }
            if (fileds == "")
            {
                return;
            }
            fileds = fileds.Remove(fileds.Length - 1);

            //显示相应03单单号
            if (receiptTypeID == "01")
            {
                fileds += ", ReceiptId01_03 as 对应03单单号";
            }
            if (receiptTypeID == "20")
            {
                fileds += ", ReceiptId20_03 as 对应03单单号";
            }
            if (receiptTypeID == "90")
            {
                fileds += ", ReceiptId90_03 as 对应03单单号";
            }

            strSql += fileds + " from T_Receipts_Det where ReceiptId='{0}' ";
            strSql  = string.Format(strSql, ReceiptId);

            DataTable dt = (new SqlDBConnect()).Get_Dt(strSql);

            (new InitFuncs()).InitDataGridView(this.dgvReceipt_Det, dt);
        }
        /// <summary>
        /// 根据单据模板编号 绑定显示CheckBox
        /// </summary>
        /// <param name="receTypeID"></param>
        private void showItems(string receTypeID)
        {
            btnClear_Click(null, null);

            DataTable dtMain = ReceiptModalCfgDAO.GetDatasByRTypeIDAndSummaryOrDetail(receTypeID, 0);

            if (dtMain == null || dtMain.Rows.Count <= 0)
            {
                return;
            }

            foreach (DataRow dr in dtMain.Rows)
            {
                foreach (Control o in this.panelRecMain.Controls) //在主表中查找
                {
                    if (o is CheckBox)
                    {
                        if ((o as CheckBox).Text.Trim() == dr["ShowItem"].ToString().Trim())
                        {
                            (o as CheckBox).Checked = true;
                            break;
                        }
                    }
                }
            }

            //在子表中查找
            DataTable dtDet = ReceiptModalCfgDAO.GetDatasByRTypeIDAndSummaryOrDetail(receTypeID, 1);

            if (dtDet == null || dtDet.Rows.Count <= 0)
            {
                return;
            }
            foreach (DataRow dr in dtDet.Rows)
            {
                foreach (Control o in this.panelRecDet.Controls) //在子表中查找
                {
                    if (o is CheckBox)
                    {
                        if ((o as CheckBox).Text.Trim() == dr["ShowItem"].ToString().Trim())
                        {
                            (o as CheckBox).Checked = true;
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// listBoxMain添加项时
        /// </summary>
        private void listBoxMain_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listBoxMain.Items.Count <= 0)
            {
                return;
            }
            string strItem = this.listBoxMain.Items[this.listBoxMain.Items.Count - 1].ToString().Trim();

            string receTypeID = this.comboBoxReceiptTypeID.Text.Trim();

            if (receTypeID == "")
            {
                return;
            }

            DataTable dt = ReceiptModalCfgDAO.GetDatasByRTypeID(receTypeID);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }

            string sqlWhereMainTop = "where RTypeID='{0}' and ShowItem='{1}' and SummaryOrDetail=0 and UporDown=0";

            sqlWhereMainTop = string.Format(sqlWhereMainTop, receTypeID, strItem);
            bool isExist = ReceiptModalCfgDAO.IsExistData("T_ReceiptModCfg", sqlWhereMainTop);

            if (isExist)
            {
                this.listBoxMainTop.Items.Add(strItem);
                this.listBoxMain.Items.Remove(strItem);
            }
            string sqlWhereMainButtom = "where RTypeID='{0}' and ShowItem='{1}' and SummaryOrDetail=0 and UporDown=1";

            sqlWhereMainButtom = string.Format(sqlWhereMainButtom, receTypeID, strItem);
            bool isExistButtom = ReceiptModalCfgDAO.IsExistData("T_ReceiptModCfg", sqlWhereMainButtom);

            if (isExistButtom)
            {
                this.listBoxMainBottom.Items.Add(strItem);
                this.listBoxMain.Items.Remove(strItem);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化 单据子表
        /// </summary>
        public void InitDataGridViewDetail(int type)
        {
            this.progressBar1.Value = 0;

            string receiptTypeID     = "03";//单据模板编码(假设进货单)
            string receiptId         = this.txtReceiptId.Text.Trim();
            string customerReceiptId = this.txtCustomerReceiptId.Text.Trim();
            string occurTimeFrom     = this.dtpFrom.Value.ToString().Trim();
            string occurTimeTo       = this.dtpTo.Value.ToString().Trim();

            SortedList <int, string> listReceDetailItems;//单据子表项

            listReceDetailItems = ReceiptModalCfgDAO.GetShowItems(receiptTypeID, 1, -1);

            //构造Sql
            string strSql = "select T_Receipts_Det.ReceiptId as 单据号,T_Receipt_Main.CustomerReceiptNo as 自定义单据号, T_Receipts_Det.OrderNo as 顺序号, " +
                            "CustName as 客户名称, OccurTime as 单据日期, T_MatInf.MatName as 物料名称, ";
            string fileds = "";

            if (listReceDetailItems != null)
            {
                foreach (string str in listReceDetailItems.Values)
                {
                    string filedTemp = ReceiptModCfg.GetReceiptDetailItems()[str.Trim()].Trim().Substring(2);
                    if (filedTemp == "MatId")
                    {
                        filedTemp = "T_Receipts_Det." + filedTemp;
                    }
                    fileds += filedTemp + " as " + str + ",";
                }
            }
            if (fileds == "")
            {
                return;
            }
            fileds = fileds.Remove(fileds.Length - 1);

            strSql += fileds + " from T_Receipt_Main,T_Receipts_Det,T_MatInf " +
                      " where T_Receipt_Main.ReceiptTypeID='{0}' and OccurTime > '2003-12-31' and " +          //2003-12-31之前不处理未核销
                      " T_Receipt_Main.ReceiptId=T_Receipts_Det.ReceiptId and T_Receipts_Det.MatId=T_MatInf.MatID ";
            strSql = string.Format(strSql, receiptTypeID);

            if (type == 1) //未核销查询
            {
                if (receiptId != "")
                {
                    strSql += " and T_Receipts_Det.ReceiptId='" + receiptId + "'";
                }
                if (customerReceiptId != "")
                {
                    strSql += " and T_Receipt_Main.CustomerReceiptNo='" + customerReceiptId + "'";
                }

                strSql += " and OccurTime between '{0}' And '{1}'";
                strSql  = string.Format(strSql, occurTimeFrom, occurTimeTo);
            }
            else if (type == 0) //高级查找
            {
                //添加查找窗体
                WFilter wf = new WFilter(0, "单据号", false);
                wf.strSql = strSql;
                wf.s_items.Add("单据号,T_Receipts_Det.ReceiptId,C");
                wf.s_items.Add("自定义单据号,T_Receipt_Main.CustomerReceiptNo,C");
                wf.s_items.Add("客户编码,CustId,C");
                wf.s_items.Add("客户名称,CustName,C");
                wf.s_items.Add("单据日期,OccurTime,N");
                wf.s_items.Add("物料编码,T_Receipts_Det.MatId,C");
                wf.s_items.Add("物料名称,T_MatInf.MatName,C");
                wf.btnOK.Enabled = false;
                wf.ShowDialog();

                if (wf.DialogResult == DialogResult.OK)
                {
                    //返回条件框中的sql语句
                    strSql = wf.Return_Sql;
                    int index = strSql.IndexOf(" where ");
                    if (!strSql.Substring(index + 6).Contains("OccurTime "))
                    {
                        strSql += " and (OccurTime between '{0}' And '{1}')";
                        strSql  = string.Format(strSql, occurTimeFrom, occurTimeTo);
                    }
                }
                else
                {
                    return;
                }
            }

            strSql += " order by OccurTime"; //排序

            DataTable dt = (new SqlDBConnect()).Get_Dt(strSql);

            (new InitFuncs()).InitDataGridView(this.dgvReceipt_Det, dt);

            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = dt.Rows.Count;

            try
            {
                List <DataGridViewRow> deleteRows = new List <DataGridViewRow>();
                //更新 未核销的商品数量
                foreach (DataGridViewRow dgvr in this.dgvReceipt_Det.Rows)
                {
                    string receiptId03 = "";
                    int    orderNo03   = 0;
                    string matId       = "";
                    int    matType     = 0;
                    double price       = 0;
                    int    num         = 0;
                    if (dgvr.Cells["单据号"].Value == null || dgvr.Cells["单据号"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }
                    if (dgvr.Cells["顺序号"].Value == null || dgvr.Cells["顺序号"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }
                    if (dgvr.Cells["物料编码"].Value == null || dgvr.Cells["物料编码"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }
                    if (dgvr.Cells["类型"].Value == null || dgvr.Cells["类型"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }
                    if (dgvr.Cells["单价"].Value == null || dgvr.Cells["单价"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }
                    if (dgvr.Cells["数量"].Value == null || dgvr.Cells["数量"].Value.ToString().Trim() == "")
                    {
                        continue;
                    }

                    receiptId03 = dgvr.Cells["单据号"].Value.ToString().Trim();
                    orderNo03   = Convert.ToInt32(dgvr.Cells["顺序号"].Value.ToString().Trim());
                    num         = Convert.ToInt32(dgvr.Cells["数量"].Value.ToString().Trim());
                    matId       = dgvr.Cells["物料编码"].Value.ToString().Trim();
                    matType     = Convert.ToInt32(dgvr.Cells["类型"].Value.ToString().Trim());
                    price       = Convert.ToDouble(dgvr.Cells["单价"].Value.ToString().Trim());

                    UpdateNotVerificateMatNum(receiptId03, orderNo03, num, price, dgvr, ref deleteRows);

                    this.progressBar1.Value++;
                }
                if (this.checkBox1.Checked == false)
                {
                    //删除已冲销完的行
                    foreach (DataGridViewRow row in deleteRows)
                    {
                        this.dgvReceipt_Det.Rows.Remove(row);
                    }
                }
                this.progressBar1.Value = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 初始化 单据总表
        /// </summary>
        private void InitDataGridViewMain()
        {
            string customerReceiptId = this.txtCustomerReceiptId.Text.Trim();
            string receiptTypeID     = this.txtReceTypeID.Text.Trim();
            string occurTimeFrom     = this.dtpFrom.Value.ToString().Trim();
            string occurTimeTo       = this.dtpTo.Value.ToString().Trim();

            if (receiptTypeID == "")
            {
                return;
            }

            SortedList <int, string> listReceMainTopItems    = new SortedList <int, string>(); //单据总表上部项
            SortedList <int, string> listReceMainButtomItems = new SortedList <int, string>(); //单据总表下部项

            listReceMainTopItems    = ReceiptModalCfgDAO.GetShowItems(receiptTypeID, 0, 0);
            listReceMainButtomItems = ReceiptModalCfgDAO.GetShowItems(receiptTypeID, 0, 1);

            //构造Sql
            string strSql = "select T_Receipt_Main.ReceiptTypeID as 单据类别, ";
            string fileds = "";

            if (listReceMainTopItems != null)
            {
                foreach (string str in listReceMainTopItems.Values)
                {
                    string filedTemp = ReceiptModCfg.GetReceiptMainItems()[str.Trim()].Trim();
                    if (filedTemp == "s_CustID")
                    {
                        fileds += "CustName" + " as " + str + ",";
                    }
                    else if (filedTemp == "s_SourceStoreH")
                    {
                        fileds += "T_StoreHouse.SHName" + " as " + str + ",";
                    }
                    else
                    {
                        fileds += filedTemp.Substring(2) + " as " + str + ",";
                    }
                }
            }
            if (listReceMainButtomItems != null)
            {
                foreach (string str in listReceMainButtomItems.Values)
                {
                    string filedTemp = ReceiptModCfg.GetReceiptMainItems()[str.Trim()].Trim();
                    if (filedTemp == "s_CustID")
                    {
                        fileds += "CustName" + " as " + str + ",";
                    }
                    else if (filedTemp == "s_SourceStoreH")
                    {
                        fileds += "T_StoreHouse.SHName" + " as " + str + ",";
                    }
                    else
                    {
                        fileds += filedTemp.Substring(2) + " as " + str + ",";
                    }
                }
            }
            if (fileds == "")
            {
                return;
            }
            fileds = fileds.Remove(fileds.Length - 1);

            strSql += fileds + " from T_Receipt_Main,T_StoreHouse where ReceiptTypeID='{0}' ";
            strSql  = string.Format(strSql, receiptTypeID);

            if (customerReceiptId != "")
            {
                strSql += " and CustomerReceiptNo='" + customerReceiptId + "'";
            }

            strSql += " and (OccurTime between '{0}' And '{1}') ";
            strSql  = string.Format(strSql, occurTimeFrom, occurTimeTo);

            strSql += " and T_Receipt_Main.SourceStoreH=T_StoreHouse.SHId order by OccurTime";

            DataTable dt = (new SqlDBConnect()).Get_Dt(strSql);

            (new InitFuncs()).InitDataGridView(this.dgvReceipt_Main, dt);
        }