Esempio n. 1
0
        private void DoKansaItem(Item it)
        {
            this.curItem = it;

            this.textBox_ban.Text = it.item_id.ToString();

            this.textBox_name.BackColor = SystemColors.Control;
            this.textBox_name.Text      = it.item_name;
            this.textBox_teika.Text     = it.item_tagprice.ToString("#,##0");
            this.textBox_nebiki.Text    = it.item_return /*FIXME*/ ? "×" : "○";

            if (it.item_sellprice.HasValue)
            {
                if (it.item_sellprice.Value == it.item_tagprice)
                {
                    this.textBox_baika.Text = "-- " + it.item_sellprice.Value.ToString();
                }
                else
                {
                    this.textBox_baika.Text = it.item_sellprice.Value.ToString();
                }

                if (it.item_sell__Operator != null)
                {
                    this.textBox_sellop.Text = it.item_sell__Operator.operator_name;
                }
                else
                {
                    this.textBox_sellop.Text = "不明";
                }

                this.textBox_selltime.Text = Globals.getTimeString(it.item_selltime);

                this.button_mibai.Enabled    = true;
                this.button_teisei.Enabled   = true;
                this.textBox_baika.BackColor = SystemColors.Control;


                if (it.item_kansa_end.HasValue)
                {
                    //監査済み
                    this.label_error.Text    = "監査対象ではありません。本日の販売ではない可能性が。";
                    this.label_error.Visible = true;
                }
                else
                {
                    if (this.GetKansaFlag(it).HasValue)
                    {
                        IOperatorDao    opDao = GlobalData.getIDao <IOperatorDao>();
                        List <Operator> lop   = opDao.GetById(this.GetKansaFlag(it).Value);

                        if (lop.Count() == 0)
                        {
                            this.label_error.Text = "だれかが既に監査したようです";
                        }
                        else
                        {
                            this.label_error.Text = lop[0].operator_name + " が既に監査しています";
                        }

                        this.label_error.Visible = true;
                    }
                    else
                    {
                        System.Threading.Thread t = new System.Threading.Thread(
                            delegate(object item)
                        {
                            Item itemmm = (Item)item;
                            this.SetKansaFlag(itemmm, this.nowOperator.operator_id);

                            IItemDao idao = GlobalData.getIDao <IItemDao>();
                            idao.Update(itemmm);
                        }
                            );

                        t.IsBackground = true;
                        t.Start(it);

                        this.label_error.Text = "監査しました。次の品番を入力してね";

                        this.RefreshRemain();
                    }
                }
            }
            else
            {
                this.button_teisei.Enabled   = true;
                this.button_mibai.Enabled    = false;
                this.textBox_baika.Text      = "未売却";
                this.textBox_baika.BackColor = Color.LightPink;
                this.textBox_sellop.Text     = null;
                this.textBox_selltime.Text   = null;

                this.label_error.Text    = "未売却の商品は監査できません";
                this.label_error.Visible = true;
            }

            this.textBox_ban.Focus();
            this.textBox_ban.SelectAll();
        }
Esempio n. 2
0
        private void RefreshData()
        {
            var myiDao = GlobalData.getIDao <kaede2nd.Dao.IItemDao>();
            var myGrp  =
                (from i in myiDao.GetAll()
                 //where i.item_sellprice.HasValue == true
                 group i by this.makeCompareSellerString(i.item__Receipt.getSellerString()));


            var youriDao = this.yourData.getIDao <kaede2nd.Dao.IItemDao>();
            var yourGrp  =
                (from i in youriDao.GetAll()
                 //where i.item_sellprice.HasValue == true
                 group i by this.makeCompareSellerString(i.item__Receipt.getSellerString()));

            IEqualityComparer <IGrouping <string, Item> > comp = new grpComparer <string, Item>();
            //(long?)(myg.Sum(item => (long)item.item_sellprice.Value))
            var dest = (from myg in myGrp
                        join yog in yourGrp
                        on myg.Key equals yog.Key
                        select new HenkinJoined
            {
                Key = myg.Key,
                ExampleItem = myg.First(),
                Items1 = myg.ToList(),
                Items2 = yog.ToList()
            }
                        ).Union(
                myGrp.Except(yourGrp, comp).Select(
                    ggg => new HenkinJoined
            {
                Key         = ggg.Key,
                ExampleItem = ggg.First(),
                Items1      = ggg.ToList(),
                Items2      = null
            }
                    )
                ).Union(
                yourGrp.Except(myGrp, comp).Select(
                    ggg => new HenkinJoined
            {
                Key         = ggg.Key,
                ExampleItem = ggg.First(),
                Items1      = null,
                Items2      = ggg.ToList()
            }
                    )
                );

            this.joinedlist = dest.ToList();


            this.dataGridView1.Rows.Clear();
            foreach (var j in this.joinedlist)
            {
                DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()];
                this.setRowValue(row, j);
            }

            this.dataGridView1.VirtualMode = true;
            this.dataGridView1.VirtualMode = false;
            this.dataGridView1.Enabled     = true;
            this.dataGridView1.Focus();
        }
Esempio n. 3
0
        private void kaedeOutput(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName         = GlobalData.Instance.data.companyName + ".kae";
            sfd.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath);
            sfd.Filter           = "楓ちゃん萌え萌え filez (*.kae)|*.kae";
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            bool zaikouAsOB = false;

            if (MessageBox.Show("在校生の氏名データを残しますか?\n" +
                                "はい・・・全員をOBとして扱います\n" +
                                "いいえ・・・在校生は年組番号で出力します", "在校生の扱い", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                zaikouAsOB = true;
            }


            const string kae_header       = "Kaede chan moemoe software by 51st. ennichi han";
            const int    kae_file_version = 1003;
            const int    kae_version      = 1005; //kaede_rg005

            IItemDao    itemDao = GlobalData.getIDao <IItemDao>();
            List <Item> items   = itemDao.GetAll();

            Dictionary <string, int> exSellers = new  Dictionary <string, int>();
            int exnum = 1;

            foreach (Item it in items)
            {
                if (it.item__Receipt.receipt_seller == Receipt.seller_DONATE ||
                    it.item__Receipt.receipt_seller == Receipt.seller_LAGACY)
                {
                    continue;
                }

                if (it.item__Receipt.receipt_seller == Receipt.seller_EXT || zaikouAsOB)
                {
                    string exname = it.item__Receipt.getSellerString();
                    if (!exSellers.ContainsKey(exname))
                    {
                        exSellers.Add(exname, exnum);
                        exnum++;
                    }
                }
            }

            try
            {
                using (Stream fs = sfd.OpenFile())
                {
                    BinaryWriter bw = new BinaryWriter(fs);

                    bw.Write(Encoding.ASCII.GetBytes(kae_header));
                    bw.Write(kae_file_version);
                    bw.Write(kae_version);

                    //OB
                    bw.Write(exSellers.Count);
                    foreach (var exs in exSellers)
                    {
                        bw.WriteStringSJIS(exs.Key);
                    }

                    //teacher
                    bw.Write(0);

                    //genre
                    bw.Write(0);

                    //shape
                    bw.Write(0);

                    //item
                    bw.Write(items.Count);

                    foreach (Item it in items)
                    {
                        //ID
                        bw.Write((Int32)it.item_id);


                        //Seller
                        Int32 seller;

                        string sellerstr = it.item__Receipt.receipt_seller;

                        switch (sellerstr)
                        {
                        case Receipt.seller_LAGACY:
                        {
                            seller = 0x30000000;
                            break;
                        }

                        case Receipt.seller_DONATE:
                        {
                            seller = 0x40000000;
                            break;
                        }

                        default:
                        {
                            if (sellerstr == Receipt.seller_EXT || zaikouAsOB)
                            {
                                seller = 0x10000000 + exSellers[it.item__Receipt.getSellerString()];
                                break;
                            }

                            int    nen  = int.Parse(sellerstr.Substring(0, 1));
                            string kumi = sellerstr.Substring(1, 1);
                            int    kumi_i;
                            if (Globals.isChugaku(kumi))
                            {
                                kumi_i = Globals.getChugakuClassNum(kumi);
                            }
                            else
                            {
                                nen   += 3;
                                kumi_i = int.Parse(kumi);
                            }
                            int ban = int.Parse(sellerstr.Substring(2, 2));

                            seller = 0x01000000 * nen + 0x00100000 * kumi_i + ban;
                            break;
                        }
                        }

                        bw.Write(seller);

                        bw.WriteStringSJIS(it.item_name);
                        bw.WriteStringSJIS(it.item_comment);

                        bw.Write(it.item_tagprice);
                        bw.Write(it.item_sellprice.ToKaedeInt());

                        //Genre
                        bw.Write((Int16)0);
                        bw.Write((Int16)0);
                        bw.Write((Int16)0);
                        //Shape
                        bw.Write((Int16)0);

                        //is_sold
                        bw.Write(it.item_sellprice.HasValue.ToKaedeBool());
                        //is_returned
                        bw.Write((SByte)0);
                        //to_be_return
                        bw.Write(it.item_return.ToKaedeBool());
                        //to_be_discount
                        bw.Write(it.item_tataki.ToKaedeBool());

                        if (it.item_receipt_time.HasValue)
                        {
                            bw.Write(it.item_receipt_time.Value.ToUnixTime());
                        }
                        else if (it.item__Receipt.receipt_time.HasValue)
                        {
                            bw.Write(it.item__Receipt.receipt_time.Value.ToUnixTime());
                        }
                        else
                        {
                            bw.Write((UInt32)0);
                        }

                        if (it.item_selltime.HasValue)
                        {
                            bw.Write(it.item_selltime.Value.ToUnixTime());
                        }
                        else
                        {
                            bw.Write((UInt32)0);
                        }

                        //Item_scheduled_date
                        bw.Write((SByte)0);
                        //is_by_auction
                        bw.Write((SByte)0);

                        //refund_rate
                        bw.Write((Int32)(-1));
                    }

                    //cash
                    bw.Write((Int32)888);

                    //refund_rate
                    bw.Write((Int32)100);

                    bw.Flush();
                    fs.Close();
                }

                uint[] crcTable = new uint[256];
                for (uint n = 0; n < 256; n++)
                {
                    uint c = n;
                    for (uint k = 0; k < 8; k++)
                    {
                        if ((c & 1) != 0)
                        {
                            c = 0xedb88320U ^ (c >> 1);
                        }
                        else
                        {
                            c = c >> 1;
                        }
                    }
                    crcTable[n] = c;
                }

                using (FileStream fs = new FileStream(sfd.FileName, FileMode.Open, FileAccess.ReadWrite))
                {
                    uint not_crc = 0xffffffff;

                    BinaryReader br = new BinaryReader(fs);

                    while (fs.Position < fs.Length)
                    {
                        byte data = br.ReadByte();
                        not_crc = crcTable[((not_crc) ^ (data)) & 0xff] ^ ((not_crc) >> 8);
                    }


                    BinaryWriter bw = new BinaryWriter(fs);
                    bw.Write(~not_crc);
                    bw.Flush();


                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("kaeファイルの作成エラー: " + ex.Message);
                return;
            }

            MessageBox.Show("楓ちゃん形式での出力が完了しました。");
        }
Esempio n. 4
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (this.oplist == null)
            {
                throw new InvalidOperationException();
            }

            DataGridView dgv = (DataGridView)sender;

            if (!dgv.Enabled)
            {
                return;
            }
            if (e.ColumnIndex == 0)
            {
                return;
            }

            if (dgv.Rows[e.RowIndex].IsNewRow)
            {
                return;
            }

            var      opDao = GlobalData.getIDao <IOperatorDao>();
            Operator op;

            if (dgv[ColumnName.operatorId, e.RowIndex].Value == null)
            {
                op = new Operator();

                foreach (KeyValuePair <string, ColumnInfo> kvp in this.colinfos)
                {
                    this.changeDBdata(kvp.Key, op, dgv[kvp.Key, e.RowIndex].Value);
                }

                opDao.Insert(op);
                dgv[ColumnName.operatorId, e.RowIndex].Value = op.operator_id;

                this.oplist.Add(op);
            }
            else
            {
                var ops = from i in this.oplist where i.operator_id == ((uint)dgv[ColumnName.operatorId, e.RowIndex].Value) select i;
                if (ops.Count() == 0)
                {
                    return;
                }

                op = ops.Single();

                this.changeDBdata(dgv.Columns[e.ColumnIndex].Name, op, dgv[e.ColumnIndex, e.RowIndex].Value);

                try
                {
                    opDao.Update(op);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("更新できませんでした: " + ex.Message);
                    return;
                }
            }
        }
Esempio n. 5
0
        private void Connect(SQLType dbtype)
        {
            DatabaseAccess data;

            if (this.DbAccessSetter == null)
            {
                GlobalData.makeInstance(text_host.Text, text_port.Text, text_user.Text, text_pass.Text, text_dbname.Text, dbtype);
                GlobalData.Instance.data.isReadonly = checkBox_MySQL_readonly.Checked;
                data = GlobalData.Instance.data;
            }
            else
            {
                data            = new DatabaseAccess(text_host.Text, text_port.Text, text_user.Text, text_pass.Text, text_dbname.Text, dbtype);
                data.isReadonly = true;
                this.DbAccessSetter(data);
            }

            //Config取得
            DbConfig cfg = null;

            try
            {
                cfg = DbConfig.MakeFromDB(data);
            }
            catch (Exception ecfg)
            {
                MessageBox.Show("データベースから設定が取得できませんでした。正しい接続先・ファイルを指定していますか?\n"
                                + ecfg.Message);
                if (this.DbAccessSetter == null)
                {
                    GlobalData.disposeInstance();
                }
                else
                {
                    this.DbAccessSetter(null);
                }
                return;
            }

            data.bumonName      = cfg.getValue("bumonname");
            data.companyName    = cfg.getValue("companyname");
            data.symbolColor    = System.Drawing.Color.FromArgb(cfg.getValueInt("symbolcolor_argb"));
            data.bumonTextColor = System.Drawing.Color.FromArgb(cfg.getValueInt("bumontextcolor_argb"));

            if (this.DbAccessSetter == null)
            {
                GlobalData.Instance.windowTitle = "ゆかり姫萌え萌えソフトウェア";

                GlobalData.Instance.barcodePrefix = cfg.getValue("barcodeprefix");
                if (!Globals.isValidBarcodePrefix(GlobalData.Instance.barcodePrefix))
                {
                    MessageBox.Show("バーコード識別子 (barcodeprefix) が不正です。正常なバーコードが印刷されませんよ");
                    GlobalData.Instance.barcodePrefix = "00";
                }
                GlobalData.Instance.itemNameImeOn = cfg.getValueBool("itemname_imeon");
                GlobalData.Instance.enterToTab    = cfg.getValueBool("entertotab");

                Program.config.BackupDirectory = this.textBox_backupdest.Text;

                GlobalData.Instance.recentItemForm = new RecentItem();
            }

            if (data.db_type == SQLType.SQLite)
            {
                Program.config.AddRecentSQLite(data.companyName, text_dbname.Text);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 6
0
        private void SetReceipt(kaede2nd.Entity.Receipt r)
        {
            this.receipt              = r;
            this.isNewReceipt         = false;
            this.label_sakini.Visible = false;

            this.Text           = "受付票: " + r.receipt_id.ToString("'R'0000") + " (" + GlobalData.Instance.data.bumonName + ")";
            this.text_rid.Text  = r.receipt_id.ToString("'R'0000");
            this.text_pass.Text = r.receipt_pass;

            switch (r.receipt_seller)
            {
            case kaede2nd.Entity.Receipt.seller_EXT:
            {
                this.text_external.Text = r.receipt_seller_exname;
                this.radio_external.Select();
                break;
            }

            case kaede2nd.Entity.Receipt.seller_LAGACY:
            {
                this.radio_legacy.Select();
                break;
            }

            case kaede2nd.Entity.Receipt.seller_DONATE:
            {
                this.radio_donate.Select();
                break;
            }

            default:
                /*
                 * if (this.receipt_seller.Substring(0, 1) == "9")
                 * {
                 *  return "ERR: 不明";
                 * }
                 */
                this.radio_zaigaku.Select();
                this.text_zai_nen.Text  = r.receipt_seller.Substring(0, 1);
                this.text_zai_kumi.Text = r.receipt_seller.Substring(1, 1);
                this.text_zai_ban.Text  = r.receipt_seller.Substring(2, 2);
                this.text_external.Text = r.receipt_seller_exname;
                break;
            }

            this.dataGridView1.Enabled = false;
            this.dataGridView1.Rows.Clear();

            var itemDao = GlobalData.getIDao <IItemDao>();

            this.itemList = itemDao.GetReceiptItem(r.receipt_id);

            foreach (Item it in this.itemList)
            {
                DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()];

                this.setRowValue(row, it);
            }

            this.dataGridView1.VirtualMode          = true;
            this.dataGridView1.VirtualMode          = false;
            this.dataGridView1.Enabled              = true;
            this.商品リストを表示LToolStripMenuItem.Enabled = true;
        }
Esempio n. 7
0
        private void text_Enter_SelectAll(object sender, EventArgs e)
        {
            if (sender == this.text_external)
            {
                do
                {
                    if (this.text_external.Text != "")
                    {
                        break;
                    }

                    int nen;
                    //正規化
                    if (int.TryParse(this.text_zai_nen.Text, out nen) == false || !(1 <= nen && nen <= 3))
                    {
                        break;
                    }

                    if (string.IsNullOrEmpty(this.text_zai_kumi.Text))
                    {
                        break;
                    }
                    string kumi = this.text_zai_kumi.Text.ToUpperInvariant().Substring(0, 1);
                    if (kumi != "1" && kumi != "2" && kumi != "3" && kumi != "4" &&
                        kumi != "A" && kumi != "B" && kumi != "C")
                    {
                        break;
                    }

                    int ban;
                    if (int.TryParse(this.text_zai_ban.Text, out ban) == false || !(0 <= ban && ban <= 99))
                    {
                        break;
                    }

                    string seller = nen.ToString("0") + kumi + ban.ToString("00");

                    var            receiptDao = GlobalData.getIDao <IReceiptDao>();
                    List <Receipt> reces      = receiptDao.GetBySellerString(seller);

                    var names = from r in reces select r.receipt_seller_exname;
                    this.text_external.Items.AddRange(names.Distinct().ToArray());

                    if (reces.Count == 0)
                    {
                        break;
                    }
                    else
                    {
                        this.text_external.Text = reces[0].receipt_seller_exname;
                    }
                } while (false);
            }

            if (sender is TextBox)
            {
                ((TextBox)sender).SelectAll();
            }
            else if (sender is ComboBox)
            {
                ((ComboBox)sender).SelectAll();
            }
        }
Esempio n. 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.isNewReceipt)
                {
                    this.receipt = new Receipt();
                }

                receipt.receipt_pass = this.text_pass.Text;

                if (this.radio_external.Checked)
                {
                    receipt.receipt_seller        = kaede2nd.Entity.Receipt.seller_EXT;
                    receipt.receipt_seller_exname = this.text_external.Text;
                }
                else if (this.radio_legacy.Checked)
                {
                    receipt.receipt_seller        = kaede2nd.Entity.Receipt.seller_LAGACY;
                    receipt.receipt_seller_exname = null;
                }
                else if (this.radio_donate.Checked)
                {
                    receipt.receipt_seller        = kaede2nd.Entity.Receipt.seller_DONATE;
                    receipt.receipt_seller_exname = null;
                }
                else
                { //在学
                    int nen;
                    //正規化
                    if (int.TryParse(this.text_zai_nen.Text, out nen) == false || !(1 <= nen && nen <= 3))
                    {
                        this.text_zai_nen.Focus();
                        throw new Exception("学年の値が不正です");
                    }


                    if (string.IsNullOrEmpty(this.text_zai_kumi.Text))
                    {
                        this.text_zai_kumi.Focus();
                        throw new Exception("組の値が空です");
                    }

                    string kumi = this.text_zai_kumi.Text.ToUpperInvariant().Substring(0, 1);
                    if (kumi != "1" && kumi != "2" && kumi != "3" && kumi != "4" &&
                        kumi != "A" && kumi != "B" && kumi != "C")
                    {
                        this.text_zai_kumi.Focus();
                        throw new Exception("組の値が不正です");
                    }

                    int ban;
                    if (int.TryParse(this.text_zai_ban.Text, out ban) == false || !(0 <= ban && ban <= 99))
                    {
                        this.text_zai_ban.Focus();
                        throw new Exception("出席番号の値が不正です");
                    }

                    receipt.receipt_seller        = nen.ToString("0") + kumi + ban.ToString("00");
                    receipt.receipt_seller_exname = this.text_external.Text;
                }
            }
            catch (Exception excep)
            {
                if (this.isNewReceipt)
                {
                    this.receipt = null;
                }
                MessageBox.Show(excep.Message);
                return;
            }

            var receiptDao = GlobalData.getIDao <IReceiptDao>();

            if (this.isNewReceipt)
            {
                receipt.receipt_time = DateTime.Now;

                receiptDao.Insert(receipt);
                //this.text_rid.Text = receipt.receipt_id.ToString("'R'0000");
                this.SetReceipt(receipt);

                //this.itemList = new List<Item>();
                //this.isNewReceipt = false;
                //this.dataGridView1.Enabled = true;

                this.dataGridView1.ClearSelection();
                this.dataGridView1.Rows[0].Cells[ColumnName.shouhinMei].Selected = true;
                this.dataGridView1.Focus();
            }
            else
            {
                try
                {
                    receiptDao.Update(receipt);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("更新できませんでした: " + ex.Message);
                    return;
                }
                this.SetReceipt(receipt);
            }
        }
Esempio n. 9
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (this.receipt == null)
            {
                return;
            }

            DataGridView dgv = (DataGridView)sender;

            if (!dgv.Enabled)
            {
                return;
            }
            if (e.ColumnIndex == 0)
            {
                return;
            }

            if (dgv.Rows[e.RowIndex].IsNewRow)
            {
                return;
            }

            if (this.itemList == null)
            {
                throw new InvalidOperationException();
            }

            if (dgv.Columns[e.ColumnIndex].Name == ColumnName.shouhinMei)
            {
                this.ConvBarcode(dgv[e.ColumnIndex, e.RowIndex]);
            }

            var  itemDao = GlobalData.getIDao <IItemDao>();
            Item it;

            if (dgv[ColumnName.shinaBan, e.RowIndex].Value == null)
            {
                it = new Item();
                it.item_receipt_id   = this.receipt.receipt_id;
                it.item__Receipt     = this.receipt;
                it.item_receipt_time = DateTime.Now;

                foreach (KeyValuePair <string, ColumnInfo> kvp in this.colinfos)
                {
                    this.changeDBdata(kvp.Key, it, dgv[kvp.Key, e.RowIndex].Value);
                }

                itemDao.Insert(it);
                dgv[ColumnName.shinaBan, e.RowIndex].Value = it.item_id;

                this.itemList.Add(it);

                GlobalData.Instance.recentItemForm.AddRecentItemId(it.item_id);
            }
            else
            {
                it = this.GetItemFromList((UInt32)dgv[ColumnName.shinaBan, e.RowIndex].Value);
                this.changeDBdata(dgv.Columns[e.ColumnIndex].Name, it, dgv[e.ColumnIndex, e.RowIndex].Value);

                try
                {
                    itemDao.Update(it);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("更新できませんでした: " + ex.Message);
                    return;
                }
            }
        }