Пример #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            crpReceipt rpt = new crpReceipt();

            rpt.Site = this.Site;
            return(rpt);
        }
Пример #2
0
        //会計処理(会計の所でエンターが押された)
        private void txtKeepMoney_KeyDown(object sender, KeyEventArgs e)
        {
            string strTotalMoney = txtTotalMoney.Text;
            string strTax        = txtTax.Text;

            if (e.KeyCode == Keys.Enter)
            {
                //貸出時の処理
                if (lblLone.BackColor == Color.Blue)
                {
                    //お預かり金が入力されている
                    if (txtKeepMoney.Text != "")
                    {
                        //お預かり金が合計金額より大きいならば
                        if (int.Parse(txtKeepMoney.Text) >= int.Parse(strTotalMoney))
                        {
                            //お釣りを計算して入力
                            txtChange.Text = (int.Parse(txtKeepMoney.Text) - int.Parse(strTotalMoney)).ToString();
                        }

                        if (txtChange.Text != "")
                        {
                            //DGVを返却予定日が早い順にソートする。
                            dgvRentalShow.Sort(dgvRentalShow.Columns[7], ListSortDirection.Ascending);

                            ////////////////////////////////////////
                            //DBへインサートする構文
                            ////////////////////////////////////////

                            //DB接続

                            cn.Open();
                            cmd.Connection = cn;
                            //伝票番号の一番大きな値を検索する
                            cmd.CommandText = "SELECT MAX(Sale_SaleNumber) AS Sale_SaleNumber FROM SaleT;";
                            OleDbDataReader rs = cmd.ExecuteReader();
                            rs.Read();
                            string strSaleNumber = Convert.ToString(rs.GetInt32(0) + 1);
                            cn.Close();

                            //売上を更新
                            cn.Open();
                            string strGoods_Code = dgvRentalShow[1, 0].Value.ToString();
                            cmd.CommandText = "INSERT INTO "
                                              + "SaleT(Sale_SaleNumber,Sale_LoanDivisionId,Sale_KeepMoney,Sale_ChangeMoney,Sale_TotalManey,Sale_MemberId,Sale_SaleDate,Sale_StaffId) "
                                              + "VALUES("
                                              + strSaleNumber + ",'"                   //伝票番号
                                              + "貸出" + "',"                            //貸出区分
                                              + txtKeepMoney.Text + ","                //お預かり金
                                              + txtChange.Text + ","                   //お釣り
                                              + strTotalMoney + ",'"                   //合計金額
                                              + txtMemberId.Text + "','"               //会員番号
                                              + System.DateTime.Now.ToString() + "','" //今日の日付
                                              + lblStaffName.Text                      //貸しだした人
                                              + "');";
                            cmd.ExecuteNonQuery();
                            cn.Close();

                            //売上明細にデータをインサート
                            cn.Open();
                            //DGVの行分繰り返す
                            for (int i = 0; i < dgvRentalShow.Rows.Count; i++)
                            {
                                cmd.CommandText = "INSERT INTO SaleListT("
                                                  + "SaleList_SaleNumber,"  //①売上番号
                                                  + "SaleList_StockId,"     //②在庫番号
                                                  + "SaleList_Money,"       //③金額
                                                  + "SaleList_NightCount,"  //④泊数
                                                  + "SaleList_ProductName," //⑤商品名
                                                  + "SaleList_LoanDivision"
                                                  + ",SaleList_ReturnDate"
                                                  + ")"
                                                  + " VALUES("
                                                  + "'" + strSaleNumber + "',"                             //売上番号
                                                  + "'" + dgvRentalShow[0, i].Value.ToString() + "',"      //在庫番号
                                                  + dgvRentalShow[6, i].Value.ToString() + ","             //金額
                                                  + dgvRentalShow[3, i].Value.ToString() + ","             //泊数
                                                  + "'" + dgvRentalShow[1, i].Value.ToString() + "'" + "," //商品名
                                                  + "'" + dgvRentalShow[2, i].Value.ToString() + "'"       //貸出区分
                                                  + "," + "'" + System.DateTime.Now.AddDays(int.Parse(dgvRentalShow[3, i].Value.ToString())).ToShortDateString() + "'"
                                                  + ");";
                                cmd.ExecuteNonQuery();
                            }
                            cn.Close();

                            //////////////////////
                            //ビデオを貸し出す
                            ////////////////
                            cn.Open();
                            for (int i = 0; i < dgvRentalShow.Rows.Count; i++)
                            {
                                string strSqlUpdate = "UPDATE StockT SET Stock_LoanCheck = 0 WHERE Stock_StockId = '"
                                                      + dgvRentalShow[0, i].Value.ToString()
                                                      + "';";
                                cmd.CommandText = strSqlUpdate;
                                cmd.ExecuteNonQuery();
                            }
                            cn.Close();

                            ////////////////////////////
                            //来店数を加算する
                            ////////////////////////////
                            int intMemberTotalCome = int.Parse(lblMember_TotalCome.Text);//総来店数
                            intMemberTotalCome++;
                            string strMemberId = txtMemberId.Text;
                            SqlInsert("UPDATE MemberT SET MemberT.Member_TotalCome = " + intMemberTotalCome.ToString()
                                      + ", MemberT.Member_LastCome = '" + System.DateTime.Now.ToShortDateString() + "' "
                                      + "WHERE (((MemberT.Member_MemberId)='" + strMemberId + "'));");


                            ////////////////////////////
                            //クリスタルレポート
                            ////////////////////////////


                            //DGVの行が無くなるまで繰り返す。
                            while (0 < dgvRentalShow.RowCount)
                            {
                                //データセットの宣言
                                Receipt dst = new Receipt();
                                //売上
                                Receipt.dtReceiptRow tr = (Receipt.dtReceiptRow)dst.dtReceipt.NewRow();
                                tr.BeginEdit();
                                tr.ReceiptNumber = strSaleNumber;   //売上番号
                                //ヘッダー
                                tr.StoreName = lblStoreName.Text;   //店舗名(仮)
                                tr.StoreTel  = "TEL xxx-xxxx-xxxx"; //店舗電話番号(仮)
                                tr.LendDiv   = "貸出レシート";
                                tr.SaleDate  = "営業日 " + lblNowTime.Text;
                                tr.MemberId  = txtMemberId.Text;

                                tr.TotalMoney     = strTotalMoney;
                                tr.TaxMoney       = strTax;
                                tr.CashMoneyTotal = strTotalMoney;
                                tr.KeepMoney      = txtKeepMoney.Text;
                                tr.ChangeMoney    = txtChange.Text;
                                tr.ReturnDate     = dgvRentalShow[7, 0].Value.ToString();
                                tr.RegisterNumber = "001";
                                tr.SaleNumber     = strSaleNumber;
                                tr.Staff          = lblStaffName.Text; //店員名
                                tr.EndEdit();
                                dst.dtReceipt.Rows.Add(tr);


                                string strStockDate       = dgvRentalShow[7, 0].Value.ToString();
                                string strStock_ProductId = dgvRentalShow[8, 0].Value.ToString();
                                int[]  intRemoveList      = new int[10];
                                int    k = 0;

                                //売上明細      //DGVの行数分
                                for (int j = 0; j < dgvRentalShow.RowCount; j++)
                                {
                                    //返却日が一番上の商品と同じ商品を抽出
                                    if (dgvRentalShow[7, j].Value.ToString() == strStockDate)
                                    {
                                        //データテーブルへ入れる
                                        Receipt.ReserveRow RLT = (Receipt.ReserveRow)dst.Reserve.NewRow();
                                        RLT.BeginEdit();
                                        RLT.DataColumn1 = dgvRentalShow[2, j].Value.ToString(); //貸出区分
                                        RLT.DataColumn2 = dgvRentalShow[1, j].Value.ToString(); //商品名
                                        RLT.DataColumn3 = dgvRentalShow[6, j].Value.ToString(); //価格
                                        RLT.DataColumn4 = dgvRentalShow[3, j].Value.ToString(); //泊数
                                        RLT.EndEdit();
                                        dst.Reserve.Rows.Add(RLT);
                                        k++;
                                    }
                                }
                                for (int Y = 0; Y < k; Y++)
                                {
                                    dgvRentalShow.Rows.RemoveAt(0);
                                }

                                //おすすめ商品にアクセスしデータを受け取る
                                var clReco = new clsDbJoin.clRecommendData();

                                clReco = clsDbj.GetRecommendation(strStock_ProductId, txtMemberId.Text);

                                //レコメンド1
                                Receipt.dtRecommendRow trr = (Receipt.dtRecommendRow)dst.dtRecommend.NewRow();
                                trr.BeginEdit();
                                trr.ProductName = clReco.strProductName;
                                trr.Comment     = clReco.strDetail;
                                trr.EndEdit();
                                dst.dtRecommend.Rows.Add(trr);

                                //クリスタルレポートヴューに出力する。
                                crpReceipt cr = new crpReceipt(); //クリスタルレポートの宣言
                                cr.SetDataSource(dst);            //データセットをクリスタルレポートにセット
                                frmShowReceipt newForm = new frmShowReceipt();
                                newForm.crvShowReceipt.ReportSource = cr;
                                newForm.ShowDialog();
                            }
                            //オールクリア
                            btnAllClear_Click(sender, e);
                        }
                    }
                }
                else
                {
                    //伝票番号の一番大きな値を取得する

                    int intSaleNumber = Convert.ToInt32(clsDbj.GetTopRow("SELECT MAX(Sale_SaleNumber) AS Sale_SaleNumber FROM SaleT;"));
                    intSaleNumber++;
                    string strSaleNumber = intSaleNumber.ToString();


                    //預かり金が見入力なら
                    if (txtKeepMoney.Text == "")
                    {
                        txtKeepMoney.Text = "0";
                        txtChange.Text    = "0";
                    }

                    //返却金が見入力なら
                    if (txtChange.Text == "")
                    {
                        txtChange.Text = "0";
                    }



                    //売上を追加
                    string strGoods_Code = dgvReturnShow[1, 0].Value.ToString();
                    SqlInsert("INSERT INTO SaleT(Sale_SaleNumber,Sale_LoanDivisionId,Sale_KeepMoney,Sale_ChangeMoney,Sale_TotalManey,Sale_MemberId,Sale_SaleDate,Sale_StaffId) VALUES("
                              + strSaleNumber + ",'"                   //売上番号
                              + "返却" + "',"                            //貸出区分
                              + txtKeepMoney.Text + ","                //お預かり金
                              + txtChange.Text + ","                   //お釣り
                              + strTotalMoney + ",'"                   //合計金額
                              + txtMemberId.Text + "','"               //会員番号
                              + System.DateTime.Now.ToString() + "','" //今日の日付
                              + lblStaffName.Text                      //延滞処理を行った人
                              + "');");


                    //売上明細を更新
                    //DGVの行分繰り返す
                    for (int i = 0; i < dgvReturnShow.Rows.Count; i++)
                    {
                        SqlInsert("INSERT INTO SaleListT(SaleList_SaleNumber,SaleList_StockId,SaleList_Money,SaleList_NightCount) VALUES('"
                                  + strSaleNumber + "','"                                 //売上番号
                                  + dgvReturnShow[0, i].Value.ToString() + "',"           //在庫番号
                                  + int.Parse(dgvReturnShow[7, i].Value.ToString()) + "," //単価
                                  + int.Parse(dgvReturnShow[6, i].Value.ToString())       //泊数
                                  + ");");
                    }

                    //////////////////////////////////////
                    //貸出区分を返却にする

                    for (int i = 0; i < dgvReturnShow.Rows.Count; i++)
                    {
                        SqlInsert("UPDATE StockT SET Stock_LoanCheck = 1 WHERE Stock_StockId = '"
                                  + dgvReturnShow[0, i].Value.ToString()
                                  + "';");
                    }


                    //オールクリア
                    btnAllClear_Click(sender, e);
                }
            }
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            ////////////////////////////
            //クリスタルレポート
            ////////////////////////////

            //データセットの宣言
            Receipt ds = new Receipt();

            //売上
            Receipt.dtReceiptDataTable dtrrr = new Receipt.dtReceiptDataTable();

            Receipt.dtReceiptRow tr = (Receipt.dtReceiptRow)ds.dtReceipt.NewRow();
            tr.BeginEdit();


            tr.StoreTel  = "090-4288-8148";   //店舗電話番号(仮)
            tr.StoreName = "HAL支店";           //店舗名(仮)

            tr.ReceiptNumber = "001";
            tr.Recommend     = "";
            tr.TotalCount    = "";

            tr.EndEdit();
            ds.dtReceipt.Rows.Add(tr);

            //売上明細
            //並び替える列を決める
            //DataGridViewColumn sortColumn = dgvRentalShow.CurrentCell.OwningColumn;
            ////並び替えの方向(昇順か降順か)を決める
            //ListSortDirection sortDirection = ListSortDirection.Ascending;
            //if (dgvRentalShow.SortedColumn != null &&
            //    dgvRentalShow.SortedColumn.Equals(sortColumn))
            //{
            //    sortDirection =
            //        dgvRentalShow.SortOrder == SortOrder.Ascending ?
            //        ListSortDirection.Descending : ListSortDirection.Ascending;
            //}
            ////並び替えを行う
            //dgvRentalShow.Sort(sortColumn, sortDirection);
            //for (int i = 0; i < dgvRentalShow.Rows.Count; i++)
            //{
            //   // string strReturnDate = dgvRentalShow[7, i].Value.ToString();
            //   // if(dgvRentalShow[7, i].Value.ToString() == strReturnDate){
            //        Receipt.dtReceiptListRow trl = (Receipt.dtReceiptListRow)ds.dtReceiptList.NewRow();
            //        trl.BeginEdit(); ;
            //        trl.LendDivision= dgvRentalShow[2, i].Value.ToString();//貸出区分
            //        trl.ProductName = dgvRentalShow[1, i].Value.ToString();//商品名
            //        trl.NightCount  = dgvRentalShow[3, i].Value.ToString();//泊数
            //        trl.Price       = dgvRentalShow[6, i].Value.ToString();//価格
            //        trl.EndEdit();
            //        ds.dtReceiptList.Rows.Add(trl);
            //   // }
            //}

            ////レコメンド
            //Receipt.dtRecommendRow trr = (Receipt.dtRecommendRow)ds.dtRecommend.NewRow();
            //trr.BeginEdit();
            //trr.ProductName = "バイオハザード";
            //trr.EndEdit();
            //ds.dtRecommend.Rows.Add(trr);

            //クリスタルレポート側



//            dhhhh.Rows.Add("100");
            crpReceipt cr = new crpReceipt(); //クリスタルレポートの宣言

            cr.SetDataSource(ds);             //データセットをクリスタルレポートにセット
            ShowReceipt newForm = new ShowReceipt();

            newForm.crvShowReceipt.ReportSource = cr;
            newForm.ShowDialog();
        }