public void RefreshData() { IItemDao iDao = GlobalData.getIDao <IItemDao>(); List <Item> items = iDao.GetAll(); this.itemGroup = (from i in items group i by i.item__Receipt.getSellerString()) .OrderByDescending(g => this.countHenpinItems(g)); this.dataGridView1.Rows.Clear(); foreach (var g in this.itemGroup) { DataGridViewRow row = this.dataGridView1.Rows[this.dataGridView1.Rows.Add()]; this.setRowValue(row, g); } this.dataGridView1.VirtualMode = true; this.dataGridView1.VirtualMode = false; this.dataGridView1.Enabled = true; this.dataGridView1.Focus(); }
public IEnumerable <Item> Get() { var items = _itemDao.GetAll(); return(items); }
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("楓ちゃん形式での出力が完了しました。"); }