예제 #1
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                BarcodeTemplate m_Template = new BarcodeTemplate();
                m_Template.CreatedAt = DateTime.Now;
                m_Template.OwnerID   = Program.User.WorksAtID;
                m_Template.Name      = this.Name_Box.Text;
                m_Template.Path      = this.Path_Box.Text;
                m_Template.Width     = Convert.ToInt32(this.Width_Num.Value);
                m_Template.Height    = Convert.ToInt32(this.Height_Num.Value);

                if (this.IsDefault_Check.Checked)
                {
                    m_Context.BarcodeTemplates.Where(q => q.OwnerID == Program.User.WorksAtID).All(delegate(BarcodeTemplate template)
                    {
                        template.IsDefault = false;
                        return(true);
                    });
                }

                m_Template.IsDefault = this.IsDefault_Check.Checked;

                m_Context.BarcodeTemplates.Add(m_Template);
                m_Context.SaveChanges();

                this.Close();
            }
        }
예제 #2
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                BarcodeTemplate m_Actual = m_Context.BarcodeTemplates.Where(q => q.ID == this.Template.ID).FirstOrDefault();

                if (m_Actual != null)
                {
                    m_Actual.Name   = this.Name_Box.Text;
                    m_Actual.Path   = this.Path_Box.Text;
                    m_Actual.Width  = Convert.ToInt32(this.Width_Num.Value);
                    m_Actual.Height = Convert.ToInt32(this.Height_Num.Value);

                    if (this.IsDefault_Check.Checked)
                    {
                        m_Context.BarcodeTemplates.Where(q => q.OwnerID == Program.User.WorksAtID).All(delegate(BarcodeTemplate template)
                        {
                            template.IsDefault = false;
                            return(true);
                        });
                    }

                    m_Actual.IsDefault = this.IsDefault_Check.Checked;

                    m_Context.SaveChanges();
                    InvokeItemEdited(m_Actual);
                }
                else
                {
                    MessageBox.Show("Düzenlemeye çalıştığınız tasarım artık yok.", "Hata", MessageBoxButtons.OK);
                }

                this.Close();
            }
        }
예제 #3
0
        private void Edit_Button_Click(object sender, EventArgs e)
        {
            if (this.BarcodeTemplates_List.SelectedItems.Count > 0)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    ListViewItem m_Item   = this.BarcodeTemplates_List.SelectedItems[0];
                    int          m_ItemID = Convert.ToInt32(m_Item.Tag);

                    if (m_ItemID > 0)
                    {
                        BarcodeTemplate m_Template = m_Context.BarcodeTemplates.Where(q => q.ID == m_ItemID).FirstOrDefault();
                        if (m_Template != null)
                        {
                            Edit_BarcodeTemplate_Pop m_Pop = new Edit_BarcodeTemplate_Pop();
                            m_Pop.Template    = m_Template;
                            m_Pop.ItemEdited += Pop_ItemEdited;
                            m_Pop.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("Düzenleme sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Düzenleme sırasında bir hata oluştu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
예제 #4
0
        private void Delete_Button_Click(object sender, EventArgs e)
        {
            if (this.BarcodeTemplates_List.SelectedItems.Count > 0)
            {
                using (MuhasebeEntities m_Context = new MuhasebeEntities())
                {
                    ListViewItem m_Item   = this.BarcodeTemplates_List.SelectedItems[0];
                    int          m_ItemID = Convert.ToInt32(m_Item.Tag);

                    if (m_Item.Tag != null && m_ItemID > 0)
                    {
                        if (MessageBox.Show("Bu tasarım kalıcı olarak silinecek, emin misiniz?", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            BarcodeTemplate m_Template = m_Context.BarcodeTemplates.Where(q => q.ID == m_ItemID).FirstOrDefault();

                            if (m_Template != null)
                            {
                                m_Context.BarcodeTemplates.Remove(m_Template);
                                m_Context.SaveChanges();
                                m_Item.Remove();
                                PopulateListView();
                            }
                            else
                            {
                                MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Silme işlemi sırasında bir hata oluştu.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
예제 #5
0
        public void Print(string text, string barcode)
        {
            string m_Data = "";

            using (MuhasebeEntities m_Context = new MuhasebeEntities())
            {
                BarcodeTemplate m_Template = this.Company.BarcodeTemplates.Where(q => q.IsDefault == true).FirstOrDefault();

                if (m_Template == null)
                {
                    MessageBox.Show("Varsayılan barkod tasarımı belirli değil, lütfen ayarlayıp deneyiniz.", "Hata", MessageBoxButtons.OK);
                    return;
                }

                using (StreamReader m_Reader = new StreamReader(m_Template.Path, Encoding.GetEncoding(1252)))
                {
                    m_Data = m_Reader.ReadToEnd();
                }

                text = this.RemoveDiacritics(text);

                if (text.Length < 25)
                {
                    m_Data = m_Data.Replace("{LINE-1}", text);
                    m_Data = m_Data.Replace("{LINE-2}", "");
                }
                else
                {
                    m_Data = m_Data.Replace("{LINE-1}", text.Substring(0, 25));

                    int left = (text.Length - 26) > 25 ? 25 : (text.Length - 26);
                    m_Data = m_Data.Replace("{LINE-2}", text.Substring(25, left));
                }

                string barcodeText = barcode;
                string barcodeData = barcode;

                if (char.IsLetter(barcode[0]))
                {
                    barcodeData = barcodeData.Insert(3, "&D");
                }

                m_Data = m_Data.Replace("{BARCODE}", barcode);
                m_Data = m_Data.Replace("{BARCODE-TEXT}", barcodeText);
                m_Data = m_Data.Replace("{BARCODE-DATA}", barcodeData);

                string m_TempPath = Path.Combine(Program.BasePath, "Temp.prn");

                using (StreamWriter m_Writer = new StreamWriter(m_TempPath, false, Encoding.GetEncoding(1252)))
                { // ANSI Encoding
                    m_Writer.Write(m_Data);
                }

                if (this.ConnectionType.Name == "NETWORK")
                {
                    NetworkConnectionParameters m_Parameters = this.GetConnectionParameters() as NetworkConnectionParameters;
                    string m_Command = string.Format("COPY /B \"{0}\" \"{1}\"", m_TempPath, m_Parameters.Alias);
                    string m_Output  = this.ExecuteCommand(m_Command);

                    //MessageBox.Show(m_Command);
                    //MessageBox.Show(m_Output);
                }
                else
                {
                    MessageBox.Show("Bu yazıcının bağlantı türü desteklenmiyor.", "Hata", MessageBoxButtons.OK);
                }
            }
        }
예제 #6
0
 private void InvokeItemEdited(BarcodeTemplate template)
 {
     ItemEdited?.Invoke(template);
 }
예제 #7
0
 private void Pop_ItemEdited(BarcodeTemplate template)
 {
     this.PopulateListView();
 }