Example #1
0
        private void btnImportUpdate_Click(object sender, EventArgs e)
        {
            bool success = true;

            if (DialogResult.Yes == XtraMessageBox.Show("Are you sure you want to import this file? Please make sure you have backup of the database before running this update.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                OpenFileDialog od = new OpenFileDialog();
                if (DialogResult.OK == od.ShowDialog())
                {
                    StreamReader sr    = new StreamReader(new FileStream(od.FileName, FileMode.Open, FileAccess.Read), false);
                    ABC          abc   = new ABC();
                    string       query = "";
                    while (!sr.EndOfStream)
                    {
                        string str = sr.ReadLine();
                        if (str == "GO" || (sr.EndOfStream && str != ""))
                        {
                            success = abc.LoadQuery(query);
                            //XtraMessageBox.Show(query);
                            str   = "";
                            query = "";
                            continue;
                        }
                        query += "\n" + str;
                    }

                    if (success == false)
                    {
                        XtraMessageBox.Show("Your Database has been updated with errors!", "Notice");
                    }
                    else
                    {
                        XtraMessageBox.Show("Your Database has been updated! Please restart the application and try again!", "Notice");
                    }
                }
                ;
            }
        }
        private void btnImportUpdate_Click(object sender, EventArgs e)
        {
            bool success = true;
            if (DialogResult.Yes == XtraMessageBox.Show("Are you sure you want to import this file? Please make sure you have backup of the database before running this update.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                OpenFileDialog od = new OpenFileDialog();
                if (DialogResult.OK == od.ShowDialog())
                {
                    StreamReader sr = new StreamReader(new FileStream(od.FileName, FileMode.Open, FileAccess.Read), false);
                    ABC abc = new ABC();
                    string query = "";
                    while (!sr.EndOfStream)
                    {
                        string str = sr.ReadLine();
                        if (str == "GO" || (sr.EndOfStream && str != ""))
                        {

                            success = abc.LoadQuery(query);
                            //XtraMessageBox.Show(query);
                            str = "";
                            query = "";
                            continue;
                        }
                        query += "\n" + str;
                    }

                    if (success == false)
                        XtraMessageBox.Show("Your Database has been updated with errors!", "Notice");
                    else
                        XtraMessageBox.Show("Your Database has been updated! Please restart the application and try again!", "Notice");
                };
            }
        }
        private void PopulateFields()
        {
            // Bind the lookups first
            ABC abc = new ABC();
            abc.LoadAll();

            radioGroupABC.Properties.Items.Clear();
            while(!abc.EOF){
                radioGroupABC.Properties.Items.Add(new RadioGroupItem(abc.ID, abc.Description));
                abc.MoveNext();
            }

            radioGroupVEN.Properties.Items.Clear();
            VEN ven = new VEN();
            ven.LoadAll();
            while (!ven.EOF)
            {
                radioGroupVEN.Properties.Items.Add(new RadioGroupItem(ven.ID, ven.Description));
                ven.MoveNext();
            }

            if(itemId != 0)
            {
                Item itm = new Item();

                //itm.LoadByPrimaryKey(itemId);
                DataTable dtItem = itm.GetItemById(itemId);
                txtItemName.Text = itm.FullItemName;//String.Format("{0} - {1} - {2}", dtItem.Rows[0]["ItemName"], dtItem.Rows[0]["DosageForm"], dtItem.Rows[0]["Strength"]);
                ckExculed.Checked = (!itm.IsColumnNull("IsInHospitalList"))?itm.IsInHospitalList:false;

                chkProcessDecimal.Checked = (!itm.IsColumnNull("ProcessInDecimal")) ? itm.ProcessInDecimal : false;

                if (!itm.IsColumnNull("ABCID"))
                {
                    radioGroupABC.EditValue = itm.GetColumn("ABCID");
                }
                if (!itm.IsColumnNull("VENID"))
                {
                    radioGroupVEN.EditValue = itm.GetColumn("VENID");
                }

                Supplier sup = new Supplier();
                sup.LoadAll();
                ItemSupplier itmSup = new ItemSupplier();
                itmSup.GetSuppliersAndMarkThoseUsed(itemId);

                while(!itmSup.EOF)
                {
                    lstSuppliers.Items.Add(itmSup.GetColumn("CompanyName"),Convert.ToBoolean(itmSup.GetColumn("IsUsed")));
                    itmSup.MoveNext();
                }

                BLL.Program prog = new BLL.Program();
                prog.GetSubPrograms();
                ItemProgram progItem = new ItemProgram();
                lstPrograms.Items.Clear();
                foreach (DataRowView dv in prog.DefaultView)
                {
                    bool check = false;
                    check = progItem.CheckIfExists(itemId,Convert.ToInt32(dv["ID"]));
                    lstPrograms.Items.Add(dv["Name"],check);
                }
            }
        }